Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java +22 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ package app.fedilab.android.ui.fragment.timeline; * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.slugOfFirstFragment; import android.content.SharedPreferences; import android.os.Bundle; import android.view.LayoutInflater; Loading Loading @@ -57,6 +59,8 @@ public class FragmentMastodonConversation extends Fragment implements Conversati private ConversationAdapter conversationAdapter; private LinearLayoutManager mLayoutManager; public UpdateCounters update; private boolean isViewInitialized; private Conversations initialConversations; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -75,6 +79,16 @@ public class FragmentMastodonConversation extends Fragment implements Conversati route(direction, fetchingMissing, null); } @Override public void onResume() { super.onResume(); if (Timeline.TimeLineEnum.CONVERSATION.getValue().compareTo(slugOfFirstFragment) != 0 && !isViewInitialized) { isViewInitialized = true; initializeConversationCommonView(initialConversations); } } /** * Router for timelines * Loading Loading @@ -123,6 +137,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati if (conversationsCached == null || conversationsCached.conversations == null || conversationsCached.conversations.size() == 0) { getLiveConversations(null, fetchingMissing, timelineParams, null); } else { initialConversations = conversationsCached; initializeConversationCommonView(conversationsCached); } }); Loading Loading @@ -160,7 +175,10 @@ public class FragmentMastodonConversation extends Fragment implements Conversati private void getLiveConversations(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Conversation conversationToUpdate) { if (direction == null) { timelinesVM.getConversations(conversationList, timelineParams) .observe(getViewLifecycleOwner(), this::initializeConversationCommonView); .observe(getViewLifecycleOwner(), conversations -> { initialConversations = conversations; initializeConversationCommonView(conversations); }); } else if (direction == FragmentMastodonTimeline.DIRECTION.BOTTOM) { timelinesVM.getConversations(conversationList, timelineParams) .observe(getViewLifecycleOwner(), conversationsBottom -> dealWithPagination(conversationsBottom, FragmentMastodonTimeline.DIRECTION.BOTTOM, fetchingMissing, conversationToUpdate)); Loading Loading @@ -219,6 +237,9 @@ public class FragmentMastodonConversation extends Fragment implements Conversati */ private void initializeConversationCommonView(final Conversations conversations) { flagLoading = false; if (!isViewInitialized) { return; } if (binding == null || !isAdded() || getActivity() == null) { return; } Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +22 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package app.fedilab.android.ui.fragment.timeline; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.slugOfFirstFragment; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -63,6 +65,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati private boolean flagLoading; private List<Notification> notificationList; private NotificationAdapter notificationAdapter; private boolean isViewInitialized; private Notifications initialNotifications; private final BroadcastReceiver receive_action = new BroadcastReceiver() { @Override Loading Loading @@ -134,6 +138,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati ViewGroup container, Bundle savedInstanceState) { flagLoading = false; isViewInitialized = Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(slugOfFirstFragment) == 0; binding = FragmentPaginationBinding.inflate(inflater, container, false); View root = binding.getRoot(); if (getArguments() != null) { Loading Loading @@ -199,6 +204,9 @@ public class FragmentMastodonNotification extends Fragment implements Notificati */ private void initializeNotificationView(final Notifications notifications) { flagLoading = false; if (!isViewInitialized) { return; } if (binding == null || !isAdded() || getActivity() == null) { return; } Loading Loading @@ -283,6 +291,15 @@ public class FragmentMastodonNotification extends Fragment implements Notificati } @Override public void onResume() { super.onResume(); if (Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(slugOfFirstFragment) != 0 && !isViewInitialized) { isViewInitialized = true; initializeNotificationView(initialNotifications); } } /** * Router for timelines * Loading Loading @@ -343,6 +360,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati if (notificationsCached == null || notificationsCached.notifications == null || notificationsCached.notifications.size() == 0) { getLiveNotifications(null, fetchingMissing, timelineParams, null); } else { initialNotifications = notificationsCached; initializeNotificationView(notificationsCached); } }); Loading Loading @@ -380,7 +398,10 @@ public class FragmentMastodonNotification extends Fragment implements Notificati private void getLiveNotifications(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Notification notificationToUpdate) { if (direction == null) { notificationsVM.getNotifications(notificationList, timelineParams) .observe(getViewLifecycleOwner(), this::initializeNotificationView); .observe(getViewLifecycleOwner(), notifications -> { initialNotifications = notifications; initializeNotificationView(notifications); }); } else if (direction == FragmentMastodonTimeline.DIRECTION.BOTTOM) { notificationsVM.getNotifications(notificationList, timelineParams) .observe(getViewLifecycleOwner(), notificationsBottom -> dealWithPagination(notificationsBottom, FragmentMastodonTimeline.DIRECTION.BOTTOM, fetchingMissing, notificationToUpdate)); Loading Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonConversation.java +22 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ package app.fedilab.android.ui.fragment.timeline; * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.slugOfFirstFragment; import android.content.SharedPreferences; import android.os.Bundle; import android.view.LayoutInflater; Loading Loading @@ -57,6 +59,8 @@ public class FragmentMastodonConversation extends Fragment implements Conversati private ConversationAdapter conversationAdapter; private LinearLayoutManager mLayoutManager; public UpdateCounters update; private boolean isViewInitialized; private Conversations initialConversations; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Loading @@ -75,6 +79,16 @@ public class FragmentMastodonConversation extends Fragment implements Conversati route(direction, fetchingMissing, null); } @Override public void onResume() { super.onResume(); if (Timeline.TimeLineEnum.CONVERSATION.getValue().compareTo(slugOfFirstFragment) != 0 && !isViewInitialized) { isViewInitialized = true; initializeConversationCommonView(initialConversations); } } /** * Router for timelines * Loading Loading @@ -123,6 +137,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati if (conversationsCached == null || conversationsCached.conversations == null || conversationsCached.conversations.size() == 0) { getLiveConversations(null, fetchingMissing, timelineParams, null); } else { initialConversations = conversationsCached; initializeConversationCommonView(conversationsCached); } }); Loading Loading @@ -160,7 +175,10 @@ public class FragmentMastodonConversation extends Fragment implements Conversati private void getLiveConversations(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Conversation conversationToUpdate) { if (direction == null) { timelinesVM.getConversations(conversationList, timelineParams) .observe(getViewLifecycleOwner(), this::initializeConversationCommonView); .observe(getViewLifecycleOwner(), conversations -> { initialConversations = conversations; initializeConversationCommonView(conversations); }); } else if (direction == FragmentMastodonTimeline.DIRECTION.BOTTOM) { timelinesVM.getConversations(conversationList, timelineParams) .observe(getViewLifecycleOwner(), conversationsBottom -> dealWithPagination(conversationsBottom, FragmentMastodonTimeline.DIRECTION.BOTTOM, fetchingMissing, conversationToUpdate)); Loading Loading @@ -219,6 +237,9 @@ public class FragmentMastodonConversation extends Fragment implements Conversati */ private void initializeConversationCommonView(final Conversations conversations) { flagLoading = false; if (!isViewInitialized) { return; } if (binding == null || !isAdded() || getActivity() == null) { return; } Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +22 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package app.fedilab.android.ui.fragment.timeline; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.slugOfFirstFragment; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -63,6 +65,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati private boolean flagLoading; private List<Notification> notificationList; private NotificationAdapter notificationAdapter; private boolean isViewInitialized; private Notifications initialNotifications; private final BroadcastReceiver receive_action = new BroadcastReceiver() { @Override Loading Loading @@ -134,6 +138,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati ViewGroup container, Bundle savedInstanceState) { flagLoading = false; isViewInitialized = Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(slugOfFirstFragment) == 0; binding = FragmentPaginationBinding.inflate(inflater, container, false); View root = binding.getRoot(); if (getArguments() != null) { Loading Loading @@ -199,6 +204,9 @@ public class FragmentMastodonNotification extends Fragment implements Notificati */ private void initializeNotificationView(final Notifications notifications) { flagLoading = false; if (!isViewInitialized) { return; } if (binding == null || !isAdded() || getActivity() == null) { return; } Loading Loading @@ -283,6 +291,15 @@ public class FragmentMastodonNotification extends Fragment implements Notificati } @Override public void onResume() { super.onResume(); if (Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(slugOfFirstFragment) != 0 && !isViewInitialized) { isViewInitialized = true; initializeNotificationView(initialNotifications); } } /** * Router for timelines * Loading Loading @@ -343,6 +360,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati if (notificationsCached == null || notificationsCached.notifications == null || notificationsCached.notifications.size() == 0) { getLiveNotifications(null, fetchingMissing, timelineParams, null); } else { initialNotifications = notificationsCached; initializeNotificationView(notificationsCached); } }); Loading Loading @@ -380,7 +398,10 @@ public class FragmentMastodonNotification extends Fragment implements Notificati private void getLiveNotifications(FragmentMastodonTimeline.DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Notification notificationToUpdate) { if (direction == null) { notificationsVM.getNotifications(notificationList, timelineParams) .observe(getViewLifecycleOwner(), this::initializeNotificationView); .observe(getViewLifecycleOwner(), notifications -> { initialNotifications = notifications; initializeNotificationView(notifications); }); } else if (direction == FragmentMastodonTimeline.DIRECTION.BOTTOM) { notificationsVM.getNotifications(notificationList, timelineParams) .observe(getViewLifecycleOwner(), notificationsBottom -> dealWithPagination(notificationsBottom, FragmentMastodonTimeline.DIRECTION.BOTTOM, fetchingMissing, notificationToUpdate)); Loading