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) {