Avoid empty timelines

This commit is contained in:
Thomas 2022-11-02 15:48:58 +01:00
parent 0854642d81
commit 8613f57c87
3 changed files with 26 additions and 0 deletions

View file

@ -39,6 +39,7 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.api.Conversation;
import app.fedilab.android.client.entities.api.Conversations;
import app.fedilab.android.client.entities.api.Pagination;
import app.fedilab.android.client.entities.app.StatusCache;
import app.fedilab.android.client.entities.app.Timeline;
import app.fedilab.android.databinding.FragmentPaginationBinding;
@ -89,6 +90,14 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
isViewInitialized = true;
if (initialConversations != null && initialConversations.conversations != null && initialConversations.conversations.size() > 0) {
initializeConversationCommonView(initialConversations);
} else {
Conversations conversations = new Conversations();
if (conversationList != null && conversationList.size() > 0) {
conversations.pagination = new Pagination();
conversations.pagination.max_id = conversationList.get(conversationList.size() - 1).id;
conversations.pagination.min_id = conversationList.get(0).id;
}
initializeConversationCommonView(conversations);
}
}
}

View file

@ -45,6 +45,7 @@ import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.client.entities.api.Notification;
import app.fedilab.android.client.entities.api.Notifications;
import app.fedilab.android.client.entities.api.Pagination;
import app.fedilab.android.client.entities.api.Status;
import app.fedilab.android.client.entities.app.StatusCache;
import app.fedilab.android.client.entities.app.Timeline;
@ -299,6 +300,14 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
isViewInitialized = true;
if (initialNotifications != null && initialNotifications.notifications != null && initialNotifications.notifications.size() > 0) {
initializeNotificationView(initialNotifications);
} else {
Notifications notifications = new Notifications();
if (notificationList != null && notificationList.size() > 0) {
notifications.pagination = new Pagination();
notifications.pagination.max_id = notificationList.get(notificationList.size() - 1).id;
notifications.pagination.min_id = notificationList.get(0).id;
}
initializeNotificationView(notifications);
}
}
}

View file

@ -159,6 +159,14 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
isViewInitialized = true;
if (initialStatuses != null && initialStatuses.statuses != null && initialStatuses.statuses.size() > 0) {
initializeStatusesCommonView(initialStatuses);
} else {
Statuses statuses = new Statuses();
if (timelineStatuses != null && timelineStatuses.size() > 0) {
statuses.pagination = new Pagination();
statuses.pagination.max_id = timelineStatuses.get(timelineStatuses.size() - 1).id;
statuses.pagination.min_id = timelineStatuses.get(0).id;
}
initializeStatusesCommonView(statuses);
}
}
if (timelineStatuses != null && timelineStatuses.size() > 0) {