Fix empty Home when starting
This commit is contained in:
parent
cb2ede287d
commit
37838681da
|
@ -386,27 +386,27 @@ public class NotificationsHelper {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
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);
|
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();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
|
editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
|
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
|
||||||
Helper.notify_user(context, account, intent, resource, finalNotifType, finalTitle, finalMessage);
|
Helper.notify_user(context, account, intent, resource, finalNotifType, finalTitle, finalMessage);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||||
super.onLoadFailed(errorDrawable);
|
super.onLoadFailed(errorDrawable);
|
||||||
String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null);
|
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();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
since_ids.put(account.user_id + "@" + account.instance, lastNotif);
|
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.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
Helper.notify_user(context, account, intent, BitmapFactory.decodeResource(context.getResources(),
|
Helper.notify_user(context, account, intent, BitmapFactory.decodeResource(context.getResources(),
|
||||||
getMainLogo(context)), finalNotifType, finalTitle, finalMessage);
|
getMainLogo(context)), finalNotifType, finalTitle, finalMessage);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -87,6 +87,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private StatusAdapter statusAdapter;
|
private StatusAdapter statusAdapter;
|
||||||
private Timeline.TimeLineEnum timelineType;
|
private Timeline.TimeLineEnum timelineType;
|
||||||
private List<Status> timelineStatuses;
|
private List<Status> timelineStatuses;
|
||||||
|
|
||||||
|
private boolean retry_for_home_done;
|
||||||
|
|
||||||
//Handle actions that can be done in other fragments
|
//Handle actions that can be done in other fragments
|
||||||
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -376,6 +379,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
timelineType = Timeline.TimeLineEnum.HOME;
|
timelineType = Timeline.TimeLineEnum.HOME;
|
||||||
canBeFederated = true;
|
canBeFederated = true;
|
||||||
|
retry_for_home_done = false;
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
|
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
|
||||||
list_id = getArguments().getString(Helper.ARG_LIST_ID, null);
|
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);
|
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||||
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
||||||
getCachedStatus(direction, fetchingMissing, timelineParams, fetchStatus);
|
getCachedStatus(direction, fetchingMissing, timelineParams, fetchStatus);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
getLiveStatus(direction, fetchingMissing, timelineParams, true, fetchStatus);
|
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) {
|
private void getCachedStatus(DIRECTION direction, boolean fetchingMissing, TimelinesVM.TimelineParams timelineParams, Status fetchStatus) {
|
||||||
|
|
||||||
if (direction == null) {
|
if (direction == null) {
|
||||||
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
|
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
|
||||||
.observe(getViewLifecycleOwner(), statusesCached -> {
|
.observe(getViewLifecycleOwner(), statusesCached -> {
|
||||||
|
@ -913,7 +917,14 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||||
.observe(getViewLifecycleOwner(), statuses -> {
|
.observe(getViewLifecycleOwner(), statuses -> {
|
||||||
initialStatuses = 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) {
|
} else if (direction == DIRECTION.BOTTOM) {
|
||||||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||||
|
|
Loading…
Reference in New Issue