summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-05-30 08:59:28 +0200
committerThomas <tschneider.ac@gmail.com>2023-05-30 08:59:28 +0200
commit37838681dac9e9d41646e74ee7082581132c13fc (patch)
tree99f725e2cd9efbeffade3eeae669fa7df88caf9c
parentcb2ede287db9ea6b3c4716b154c1c2b803cb86ac (diff)
Fix empty Home when starting
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java8
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java15
2 files changed, 17 insertions, 6 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java
index 4dae3b5e7..32ac893fe 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java
@@ -386,27 +386,27 @@ public class NotificationsHelper {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null);
- if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
+ // if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
SharedPreferences.Editor editor = prefs.edit();
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
editor.commit();
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
Helper.notify_user(context, account, intent, resource, finalNotifType, finalTitle, finalMessage);
- }
+ // }
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null);
- if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
+ // if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) {
SharedPreferences.Editor editor = prefs.edit();
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
editor.commit();
Helper.notify_user(context, account, intent, BitmapFactory.decodeResource(context.getResources(),
getMainLogo(context)), finalNotifType, finalTitle, finalMessage);
- }
+ // }
}
@Override
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
index b0b1a0ae5..cb069d66b 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java
@@ -87,6 +87,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
private StatusAdapter statusAdapter;
private Timeline.TimeLineEnum timelineType;
private List<Status> timelineStatuses;
+
+ private boolean retry_for_home_done;
+
//Handle actions that can be done in other fragments
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
@@ -376,6 +379,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
ViewGroup container, Bundle savedInstanceState) {
timelineType = Timeline.TimeLineEnum.HOME;
canBeFederated = true;
+ retry_for_home_done = false;
if (getArguments() != null) {
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
list_id = getArguments().getString(Helper.ARG_LIST_ID, null);
@@ -794,6 +798,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
getCachedStatus(direction, fetchingMissing, timelineParams, fetchStatus);
+
} else {
getLiveStatus(direction, fetchingMissing, timelineParams, true, fetchStatus);
}
@@ -855,7 +860,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
}
private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Status fetchStatus) {
-
if (direction == null) {
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
.observe(getViewLifecycleOwner(), statusesCached -> {
@@ -913,7 +917,14 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
timelinesVM.getTimeline(timelineStatuses, timelineParams)
.observe(getViewLifecycleOwner(), statuses -> {
initialStatuses = statuses;
- initializeStatusesCommonView(statuses);
+ if (!retry_for_home_done && timelineType == Timeline.TimeLineEnum.HOME && (statuses == null || statuses.statuses.size() == 0) && timelineParams.maxId != null) {
+ retry_for_home_done = true;
+ timelineParams.maxId = null;
+ max_id = null;
+ getLiveStatus(null, fetchingMissing, timelineParams, true, fetchStatus);
+ } else {
+ initializeStatusesCommonView(statuses);
+ }
});
} else if (direction == DIRECTION.BOTTOM) {
timelinesVM.getTimeline(timelineStatuses, timelineParams)