From 363b5c2d7459f35562f33b112a548cabf3b528be Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 4 Jul 2021 20:02:43 +0900 Subject: [PATCH 1/2] Downgrade roboelectric to 4.5.1 to fix build until AGP 7. See 1. https://github.com/robolectric/robolectric/issues/6521 2. https://issuetracker.google.com/issues/159151549 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 93330c1d..49dafc60 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -245,7 +245,7 @@ dependencies { testImplementation "androidx.test.ext:junit-ktx:1.1.3" testImplementation "androidx.test:core-ktx:1.4.0" testImplementation "androidx.arch.core:core-testing:2.1.0" - testImplementation "org.robolectric:robolectric:4.6" + testImplementation "org.robolectric:robolectric:4.5.1" testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0' androidTestImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' From 506e0c5685b1adb199ea419e7d174f812b82dc0e Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 4 Jul 2021 20:32:46 +0900 Subject: [PATCH 2/2] Fix saved collections not refreshing properly on delete. Fixes austinhuang0131/barinsta#966 --- .../adapters/SavedCollectionsAdapter.java | 6 ++++-- .../fragments/SavedCollectionsFragment.java | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java index 0d6e361a..68adce59 100644 --- a/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java @@ -8,6 +8,8 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ListAdapter; +import java.util.Objects; + import awais.instagrabber.adapters.viewholder.TopicClusterViewHolder; import awais.instagrabber.databinding.ItemDiscoverTopicBinding; import awais.instagrabber.repositories.responses.saved.SavedCollection; @@ -23,10 +25,10 @@ public class SavedCollectionsAdapter extends ListAdapter { + adapter = new SavedCollectionsAdapter((topicCluster, root, cover, title, titleColor, backgroundColor) -> { final NavController navController = NavHostFragment.findNavController(this); if (isSaving) { setNavControllerResult(navController, topicCluster.getCollectionId()); @@ -160,7 +162,13 @@ public class SavedCollectionsFragment extends Fragment implements SwipeRefreshLa } }); binding.topicsRecyclerView.setAdapter(adapter); - savedCollectionsViewModel.getList().observe(getViewLifecycleOwner(), adapter::submitList); + } + + private void setupObservers() { + savedCollectionsViewModel.getList().observe(getViewLifecycleOwner(), list -> { + if (adapter == null) return; + adapter.submitList(list); + }); } private void fetchTopics(final String maxId) {