Created
January 15, 2017 16:44
-
-
Save madhu314/cdbeb6b3881cfd9fd5c1533f9ab0ec6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void add(Article article) { | |
sortedList.beginBatchedUpdates(); | |
sortedList.add(SectionArticle.createCategory(article)); | |
sortedList.add(SectionArticle.createArticle(article)); | |
sortedList.endBatchedUpdates(); | |
} | |
public void remove(Article article) { | |
SectionArticle sectionArticle = SectionArticle.createArticle(article); | |
sortedList.beginBatchedUpdates(); | |
sortedList.remove(sectionArticle); | |
int categoryCount = 0; | |
for (int i = 0; i < sortedList.size(); i++) { | |
SectionArticle sectionArticleTemp = itemAt(i); | |
if (sectionArticleTemp.isArticle() && sectionArticleTemp.article() | |
.category() | |
.equalsIgnoreCase(article.category())) { | |
categoryCount++; | |
} | |
} | |
if (categoryCount < 1) { | |
sortedList.remove(SectionArticle.createCategory(sectionArticle.article())); | |
} | |
sortedList.endBatchedUpdates(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment