Skip to content

Instantly share code, notes, and snippets.

@davidtruchet
Created June 29, 2016 21:02
Show Gist options
  • Save davidtruchet/4c0fbb3a9509bc43a6851a26e52c3655 to your computer and use it in GitHub Desktop.
Save davidtruchet/4c0fbb3a9509bc43a6851a26e52c3655 to your computer and use it in GitHub Desktop.
private void paginateLists() {
int careIndex = 0;
List<ProductAttributeModel> currentList = new ArrayList<ProductAttributeModel>();
for (ProductAttributeModel productAttributeModel : this.careTextList) {
if (careIndex != 0 && careIndex % CARE_PAGE_SIZE == 0) {
this.resultCareList.add(currentList);
currentList = new ArrayList<ProductAttributeModel>();
}
currentList.add(productAttributeModel);
careIndex++;
}
if(!currentList.isEmpty()) {
this.resultCareList.add(currentList);
}
currentList = new ArrayList<ProductAttributeModel>();
int specIndex = 0;
for (ProductAttributeModel productAttributeModel : this.populatedSpecList) {
if (specIndex != 0 && specIndex % SPECS_PAGE_SIZE == 0) {
this.resultSpecList.add(currentList);
currentList = new ArrayList<ProductAttributeModel>();
}
currentList.add(productAttributeModel);
specIndex++;
}
if(!currentList.isEmpty()) {
this.resultSpecList.add(currentList);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment