Don't reset library adapter if it's not needed

This commit is contained in:
inorichi 2016-01-18 19:41:11 +01:00
parent 8520a47286
commit f0a3c9c2dc
2 changed files with 11 additions and 5 deletions

View file

@ -32,8 +32,10 @@ public class LibraryAdapter extends SmartFragmentStatePagerAdapter {
} }
public void setCategories(List<Category> categories) { public void setCategories(List<Category> categories) {
this.categories = categories; if (this.categories != categories) {
notifyDataSetChanged(); this.categories = categories;
notifyDataSetChanged();
}
} }
public void setSelectionMode(int mode) { public void setSelectionMode(int mode) {

View file

@ -34,6 +34,7 @@ public class LibraryCategoryFragment extends BaseFragment
@State int position; @State int position;
private LibraryCategoryAdapter adapter; private LibraryCategoryAdapter adapter;
private List<Manga> mangas;
private Subscription numColumnsSubscription; private Subscription numColumnsSubscription;
@ -112,10 +113,13 @@ public class LibraryCategoryFragment extends BaseFragment
Category category = categories.get(position); Category category = categories.get(position);
List<Manga> mangas = event.getMangasForCategory(category); List<Manga> mangas = event.getMangasForCategory(category);
if (mangas == null) { if (this.mangas != mangas) {
mangas = new ArrayList<>(); this.mangas = mangas;
if (mangas == null) {
mangas = new ArrayList<>();
}
setMangas(mangas);
} }
setMangas(mangas);
} }
protected void openManga(Manga manga) { protected void openManga(Manga manga) {