From 1e94c73e100598db7c66d79bb4967a284cd6ed3b Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sat, 15 May 2021 08:21:38 +0900 Subject: [PATCH] Fix feed stories not rendered if app goes in background immediately after startup. Fixes austinhuang0131/barinsta#1258 --- .../awais/instagrabber/fragments/main/FeedFragment.java | 9 ++++++++- app/src/main/res/xml/header_list_scene.xml | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java index ea54ceca..f068f069 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java @@ -337,6 +337,12 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre return super.onOptionsItemSelected(item); } + @Override + public void onResume() { + super.onResume(); + binding.getRoot().postDelayed(feedStoriesAdapter::notifyDataSetChanged, 1000); + } + @Override public void onRefresh() { binding.feedRecyclerView.refresh(); @@ -418,15 +424,16 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre } private void fetchStories() { + if (storiesFetching) return; // final String cookie = settingsHelper.getString(Constants.COOKIE); storiesFetching = true; updateSwipeRefreshState(); storiesService.getFeedStories(new ServiceCallback>() { @Override public void onSuccess(final List result) { + storiesFetching = false; feedStoriesViewModel.getList().postValue(result); feedStoriesAdapter.submitList(result); - storiesFetching = false; if (storyListMenu != null) storyListMenu.setVisible(true); updateSwipeRefreshState(); } diff --git a/app/src/main/res/xml/header_list_scene.xml b/app/src/main/res/xml/header_list_scene.xml index 522990ee..f4a76d88 100644 --- a/app/src/main/res/xml/header_list_scene.xml +++ b/app/src/main/res/xml/header_list_scene.xml @@ -10,11 +10,11 @@ motion:layout_constraintStart_toStartOf="parent" motion:layout_constraintTop_toTopOf="parent" />