From 3d4f075c9c8b155a241a63ade99a59078b1fde89 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 21 Oct 2022 15:29:21 +0200 Subject: [PATCH] Fix cached --- .../ui/fragment/timeline/FragmentMastodonTimeline.java | 6 ++++++ .../app/fedilab/android/viewmodel/mastodon/TimelinesVM.java | 1 + 2 files changed, 7 insertions(+) diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index 8d58fa05..c8c3bf33 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -358,6 +358,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private void initializeStatusesCommonView(final Statuses statuses) { flagLoading = false; if (binding == null || !isAdded() || getActivity() == null) { + if (binding != null) { + binding.loader.setVisibility(View.GONE); + } return; } binding.loader.setVisibility(View.GONE); @@ -643,6 +646,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams) { + if (getView() == null) { + return; + } if (direction == null) { timelinesVM.getTimelineCache(timelineStatuses, timelineParams) .observe(getViewLifecycleOwner(), statusesCached -> { diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java index fa3199bc..b34655e3 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java @@ -461,6 +461,7 @@ public class TimelinesVM extends AndroidViewModel { List notPresentStatuses = new ArrayList<>(); for (Status status : statuses.statuses) { if (!timelineStatuses.contains(status)) { + status.cached = true; notPresentStatuses.add(status); } }