Fix empty timelines after GB

camel_tags
Thomas 2 years ago
parent 29995fc219
commit b12f9f2ded

@ -124,7 +124,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true); boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(Timeline.TimeLineEnum.NOTIFICATION, direction, null); TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), Timeline.TimeLineEnum.NOTIFICATION, direction, null);
timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity()); timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity());
if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) { if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) {
timelineParams.maxId = null; timelineParams.maxId = null;

@ -314,7 +314,6 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
mLayoutManager = new LinearLayoutManager(requireActivity()); mLayoutManager = new LinearLayoutManager(requireActivity());
binding.recyclerView.setLayoutManager(mLayoutManager); binding.recyclerView.setLayoutManager(mLayoutManager);
binding.recyclerView.setAdapter(notificationAdapter); binding.recyclerView.setAdapter(notificationAdapter);
binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
@ -390,7 +389,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true); boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(Timeline.TimeLineEnum.NOTIFICATION, direction, null); TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), Timeline.TimeLineEnum.NOTIFICATION, direction, null);
timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity()); timelineParams.limit = MastodonHelper.notificationsPerCall(requireActivity());
if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) { if (direction == FragmentMastodonTimeline.DIRECTION.REFRESH || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP) {
timelineParams.maxId = null; timelineParams.maxId = null;
@ -406,6 +405,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
} }
timelineParams.excludeType = getExcludeType(); timelineParams.excludeType = getExcludeType();
timelineParams.fetchingMissing = fetchingMissing; timelineParams.fetchingMissing = fetchingMissing;
if (useCache && direction != FragmentMastodonTimeline.DIRECTION.SCROLL_TOP && direction != FragmentMastodonTimeline.DIRECTION.FETCH_NEW) { if (useCache && direction != FragmentMastodonTimeline.DIRECTION.SCROLL_TOP && direction != FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
getCachedNotifications(direction, fetchingMissing, timelineParams); getCachedNotifications(direction, fetchingMissing, timelineParams);
} else { } else {

@ -757,7 +757,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
return; return;
} }
//Initialize with default params //Initialize with default params
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(timelineType, direction, ident); TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(requireActivity(), timelineType, direction, ident);
timelineParams.limit = MastodonHelper.statusesPerCall(requireActivity()); timelineParams.limit = MastodonHelper.statusesPerCall(requireActivity());
if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP || direction == DIRECTION.FETCH_NEW) { if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP || direction == DIRECTION.FETCH_NEW) {
timelineParams.maxId = null; timelineParams.maxId = null;

@ -15,6 +15,9 @@ package app.fedilab.android.mastodon.viewmodel.mastodon;
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -968,11 +971,16 @@ public class TimelinesVM extends AndroidViewModel {
public List<String> excludeVisibilities; public List<String> excludeVisibilities;
public String replyVisibility; public String replyVisibility;
public TimelineParams(@NonNull Timeline.TimeLineEnum timeLineEnum, @Nullable FragmentMastodonTimeline.DIRECTION timelineDirection, @Nullable String ident) { public TimelineParams(Context context, @NonNull Timeline.TimeLineEnum timeLineEnum, @Nullable FragmentMastodonTimeline.DIRECTION timelineDirection, @Nullable String ident) {
if (type != Timeline.TimeLineEnum.REMOTE) { if (type != Timeline.TimeLineEnum.REMOTE) {
instance = MainActivity.currentInstance; instance = MainActivity.currentInstance;
token = MainActivity.currentToken; token = MainActivity.currentToken;
userId = MainActivity.currentUserID; userId = MainActivity.currentUserID;
if (instance == null || userId == null) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
userId = sharedpreferences.getString(PREF_USER_ID, null);
}
} }
type = timeLineEnum; type = timeLineEnum;
direction = timelineDirection; direction = timelineDirection;

Loading…
Cancel
Save