Skip to content

Instantly share code, notes, and snippets.

@madhu314
Created January 15, 2017 15:00
Show Gist options
  • Save madhu314/5e2a25d91fa87e52943dcd34c8760ae4 to your computer and use it in GitHub Desktop.
Save madhu314/5e2a25d91fa87e52943dcd34c8760ae4 to your computer and use it in GitHub Desktop.
private void handleEvent(String eventName, Object data) {
if (HorizontalArticlesFragment.ITEM_CLICKED.equals(eventName)) {
Article article = (Article) data;
getHorizontalArticlesFragment().removeArticle(article.dupe());
getArticleGridFragment().addArticle(article.dupe());
} else if (ArticleGridFragment.ITEM_CLICKED.equals(eventName)) {
Article article = (Article) data;
getArticleGridFragment().removeArticle(article.dupe());
getHorizontalArticlesFragment().addArticle(article.dupe());
}
}
//somewhere else in the fragment
public void addArticle(Article article) {
dataset.add(article);
}
public void removeArticle(Article article) {
dataset.remove(article);
}
//somewhere else in the dataset
public void remove(Article article) {
sortedList.beginBatchedUpdates();
sortedList.remove(article);
sortedList.endBatchedUpdates();
}
public void add(Article article) {
sortedList.beginBatchedUpdates();
sortedList.add(article);
sortedList.endBatchedUpdates();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment