From f0a3c9c2dc761a45a790db45794ce82554c0fe83 Mon Sep 17 00:00:00 2001 From: inorichi Date: Mon, 18 Jan 2016 19:41:11 +0100 Subject: [PATCH] Don't reset library adapter if it's not needed --- .../eu/kanade/tachiyomi/ui/library/LibraryAdapter.java | 6 ++++-- .../tachiyomi/ui/library/LibraryCategoryFragment.java | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.java index c25964d6b7..bb9b3e858b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.java @@ -32,8 +32,10 @@ public class LibraryAdapter extends SmartFragmentStatePagerAdapter { } public void setCategories(List categories) { - this.categories = categories; - notifyDataSetChanged(); + if (this.categories != categories) { + this.categories = categories; + notifyDataSetChanged(); + } } public void setSelectionMode(int mode) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java index 37d69409a5..eef465aca9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.java @@ -34,6 +34,7 @@ public class LibraryCategoryFragment extends BaseFragment @State int position; private LibraryCategoryAdapter adapter; + private List mangas; private Subscription numColumnsSubscription; @@ -112,10 +113,13 @@ public class LibraryCategoryFragment extends BaseFragment Category category = categories.get(position); List mangas = event.getMangasForCategory(category); - if (mangas == null) { - mangas = new ArrayList<>(); + if (this.mangas != mangas) { + this.mangas = mangas; + if (mangas == null) { + mangas = new ArrayList<>(); + } + setMangas(mangas); } - setMangas(mangas); } protected void openManga(Manga manga) {