From 0854642d816f513ac1694eb05d6ffbd3c99a89c7 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 2 Nov 2022 12:44:42 +0100 Subject: [PATCH] Avoid empty timelines --- .../ui/fragment/timeline/FragmentMastodonConversation.java | 4 +++- .../ui/fragment/timeline/FragmentMastodonNotification.java | 4 +++- .../ui/fragment/timeline/FragmentMastodonTimeline.java | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java index 57b04639..10737a9a 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java @@ -87,7 +87,9 @@ public class FragmentMastodonConversation extends Fragment implements Conversati super.onResume(); if (Timeline.TimeLineEnum.CONVERSATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 && !isViewInitialized) { isViewInitialized = true; - initializeConversationCommonView(initialConversations); + if (initialConversations != null && initialConversations.conversations != null && initialConversations.conversations.size() > 0) { + initializeConversationCommonView(initialConversations); + } } } diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java index 644f7521..6454d819 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java @@ -297,7 +297,9 @@ public class FragmentMastodonNotification extends Fragment implements Notificati super.onResume(); if (Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 && !isViewInitialized) { isViewInitialized = true; - initializeNotificationView(initialNotifications); + if (initialNotifications != null && initialNotifications.notifications != null && initialNotifications.notifications.size() > 0) { + initializeNotificationView(initialNotifications); + } } } 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 09558e03..aad9893e 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 @@ -154,9 +154,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. @Override public void onResume() { super.onResume(); - if (slug != null && slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 && !isViewInitialized) { + if (slug != null && slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 + && !isViewInitialized) { isViewInitialized = true; - initializeStatusesCommonView(initialStatuses); + if (initialStatuses != null && initialStatuses.statuses != null && initialStatuses.statuses.size() > 0) { + initializeStatusesCommonView(initialStatuses); + } } if (timelineStatuses != null && timelineStatuses.size() > 0) { route(DIRECTION.FETCH_NEW, true);