diff --git a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java index f69ebcc9..533a116f 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java @@ -56,6 +56,7 @@ import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.enums.PostItemType; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.saved.SavedCollection; +import awais.instagrabber.utils.AppExecutors; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.utils.DownloadUtils; @@ -450,7 +451,9 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay } private void updateSwipeRefreshState() { - binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()) + ); } private void navigateToProfile(final String username) { diff --git a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java index 189820f6..f1c08306 100644 --- a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java @@ -67,7 +67,7 @@ import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.webservices.GraphQLRepository; import awais.instagrabber.webservices.ServiceCallback; -import awais.instagrabber.webservices.StoriesRepository; +//import awais.instagrabber.webservices.StoriesRepository; import awais.instagrabber.webservices.TagsService; import kotlinx.coroutines.Dispatchers; @@ -87,11 +87,11 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe private String hashtag; private Hashtag hashtagModel = null; private ActionMode actionMode; - private StoriesRepository storiesRepository; +// private StoriesRepository storiesRepository; private boolean isLoggedIn; private TagsService tagsService; private GraphQLRepository graphQLRepository; - private boolean storiesFetching; +// private boolean storiesFetching; private Set selectedFeedModels; private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_HASHTAG_POSTS_LAYOUT); private LayoutHashtagDetailsBinding hashtagDetailsBinding; @@ -280,7 +280,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe final String cookie = settingsHelper.getString(Constants.COOKIE); isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0; tagsService = isLoggedIn ? TagsService.getInstance() : null; - storiesRepository = isLoggedIn ? StoriesRepository.Companion.getInstance() : null; +// storiesRepository = isLoggedIn ? StoriesRepository.Companion.getInstance() : null; graphQLRepository = isLoggedIn ? null : GraphQLRepository.Companion.getInstance(); setHasOptionsMenu(true); } @@ -578,7 +578,9 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe } private void updateSwipeRefreshState() { - binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching() || storiesFetching); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()) + ); } private void navigateToProfile(final String username) { diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index 17f1f1b9..17aad8aa 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java @@ -64,7 +64,7 @@ import awais.instagrabber.utils.Utils; import awais.instagrabber.webservices.GraphQLRepository; import awais.instagrabber.webservices.LocationService; import awais.instagrabber.webservices.ServiceCallback; -import awais.instagrabber.webservices.StoriesRepository; +//import awais.instagrabber.webservices.StoriesRepository; import kotlinx.coroutines.Dispatchers; import static awais.instagrabber.utils.Utils.settingsHelper; @@ -81,11 +81,11 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR private long locationId; private Location locationModel; private ActionMode actionMode; - private StoriesRepository storiesRepository; +// private StoriesRepository storiesRepository; private GraphQLRepository graphQLRepository; private LocationService locationService; private boolean isLoggedIn; - private boolean storiesFetching; +// private boolean storiesFetching; private Set selectedFeedModels; private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_LOCATION_POSTS_LAYOUT); private LayoutLocationDetailsBinding locationDetailsBinding; @@ -274,7 +274,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR final String cookie = settingsHelper.getString(Constants.COOKIE); isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0; locationService = isLoggedIn ? LocationService.getInstance() : null; - storiesRepository = StoriesRepository.Companion.getInstance(); +// storiesRepository = StoriesRepository.Companion.getInstance(); graphQLRepository = isLoggedIn ? null : GraphQLRepository.Companion.getInstance(); setHasOptionsMenu(true); } @@ -578,7 +578,9 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR } private void updateSwipeRefreshState() { - binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching() || storiesFetching); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()) + ); } private void navigateToProfile(final String username) { diff --git a/app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java index 57c40b85..c7f59fcf 100644 --- a/app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/SavedViewerFragment.java @@ -39,6 +39,7 @@ import awais.instagrabber.fragments.main.ProfileFragmentDirections; import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.enums.PostItemType; import awais.instagrabber.repositories.responses.Media; +import awais.instagrabber.utils.AppExecutors; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.utils.DownloadUtils; @@ -313,7 +314,9 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL } private void updateSwipeRefreshState() { - binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()) + ); } private void navigateToProfile(final String username) { diff --git a/app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java b/app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java index acbc2eef..1d05ddca 100644 --- a/app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/TopicPostsFragment.java @@ -53,6 +53,7 @@ import awais.instagrabber.fragments.main.DiscoverFragmentDirections; import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.discover.TopicCluster; +import awais.instagrabber.utils.AppExecutors; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.ResponseBodyUtils; @@ -375,7 +376,9 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O } private void updateSwipeRefreshState() { - binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.swipeRefreshLayout.setRefreshing(binding.posts.isFetching()) + ); } private void navigateToProfile(final String username) { 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 c7f6d0b7..561473e0 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java @@ -369,7 +369,9 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre } private void updateSwipeRefreshState() { - binding.feedSwipeRefreshLayout.setRefreshing(binding.feedRecyclerView.isFetching() || storiesFetching); + AppExecutors.INSTANCE.getMainThread().execute(() -> + binding.feedSwipeRefreshLayout.setRefreshing(binding.feedRecyclerView.isFetching() || storiesFetching) + ); } private void setupFeedStories() { diff --git a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt index c8dd85e2..0784b8ed 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.kt @@ -857,7 +857,11 @@ class ProfileFragment : Fragment(), OnRefreshListener, ConfirmDialogFragmentCall .setLifeCycleOwner(this) .setPostFetchService(ProfilePostFetchService(profile, currentUser != null)) .setLayoutPreferences(layoutPreferences) - .addFetchStatusChangeListener { binding.swipeRefreshLayout.isRefreshing = it } + .addFetchStatusChangeListener { + AppExecutors.mainThread.execute { + binding.swipeRefreshLayout.isRefreshing = it + } + } .setFeedItemCallback(feedItemCallback) .setSelectionModeCallback(selectionModeCallback) .init()