diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Conversation.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Conversation.java index 5a4303991..f350cb117 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Conversation.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Conversation.java @@ -29,12 +29,12 @@ public class Conversation { public List accounts; @SerializedName("last_status") public Status last_status; - public transient boolean isFetchMore = false; + public boolean isFetchMore = false; @SerializedName("cached") public boolean cached = false; - public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; + public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; @Override public boolean equals(@Nullable Object obj) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Notification.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Notification.java index 1acea1267..9e719c4c3 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Notification.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Notification.java @@ -40,8 +40,8 @@ public class Notification { @SerializedName("cached") public boolean cached; public Filter filteredByApp; - public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; - public transient List relatedNotifications; + public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; + public List relatedNotifications; public transient boolean isFetchMore; /** diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index 09621fb78..70f70c620 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -2420,7 +2420,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = status.id; } - fetchMoreCallBack.onClickMinId(fromId, status); + fetchMoreCallBack.onClickMinId(fromId); } }); drawerFetchMoreBinding.fetchMoreMax.setOnClickListener(v -> { @@ -2432,7 +2432,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id; } - fetchMoreCallBack.onClickMaxId(fromId, status); + fetchMoreCallBack.onClickMaxId(fromId); adapter.notifyItemChanged(holder.getBindingAdapterPosition()); }); } else { @@ -2968,7 +2968,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = status.id; } - fetchMoreCallBack.onClickMinId(fromId, status); + fetchMoreCallBack.onClickMinId(fromId); } }); holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> { @@ -2981,7 +2981,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id; } - fetchMoreCallBack.onClickMaxId(fromId, status); + fetchMoreCallBack.onClickMaxId(fromId); }); } else { @@ -3025,7 +3025,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = status.id; } - fetchMoreCallBack.onClickMinId(fromId, status); + fetchMoreCallBack.onClickMinId(fromId); } }); holder.bindingFiltered.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> { @@ -3037,7 +3037,7 @@ public class StatusAdapter extends RecyclerView.Adapter } else { fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id; } - fetchMoreCallBack.onClickMaxId(fromId, status); + fetchMoreCallBack.onClickMaxId(fromId); notifyItemChanged(holder.getBindingAdapterPosition()); }); } else { @@ -3158,9 +3158,9 @@ public class StatusAdapter extends RecyclerView.Adapter public interface FetchMoreCallBack { - void onClickMinId(String min_id, Status statusToUpdate); + void onClickMinId(String min_id); - void onClickMaxId(String max_id, Status statusToUpdate); + void onClickMaxId(String max_id); void autoFetch(String min_id, String max_id, Status status); } 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 5ba1de0b3..31add35e2 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 @@ -176,7 +176,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } }; - private ViewPreloadSizeProvider preloadSizeProvider; private boolean checkRemotely; private String accountIDInRemoteInstance; private boolean isViewInitialized; @@ -196,7 +195,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private String publicTrendsDomain; private int lockForResumeCall; private boolean isNotPinnedTimeline; - private int extraCalls; + //Allow to recreate data when detaching/attaching fragment public void recreate() { @@ -342,7 +341,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. //Only fragment in main view pager should not have the view initialized //AND Only the first fragment will initialize its view flagLoading = false; - extraCalls = -1; } @@ -486,7 +484,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } else if (update != null && insertedStatus == 0 && direction == DIRECTION.REFRESH) { update.onUpdate(0, timelineType, slug); } - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); if (direction == DIRECTION.TOP && fetchingMissing && canScroll) { int position = getAbsolutePosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1)); if (position != -1) { @@ -506,26 +503,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. if (search != null) { offset += MastodonHelper.SEARCH_PER_CALL; } - int sizeBeforeFilter = 0; - int filteredMessage = 0; - int requestedMessages = MastodonHelper.statusesPerCall(requireActivity()); - sizeBeforeFilter = fetched_statuses.statuses.size(); - for (Status status : fetched_statuses.statuses) { - if (status.filteredByApp != null) { - filteredMessage++; - } - } - //TODO: keep for an improvement in beta - /* - int displayedMessages = sizeBeforeFilter - filteredMessage; - if(displayedMessages < 5 && extraCalls < 8) { - router(direction); - if(extraCalls == -1) { - extraCalls = 1; - } else { - extraCalls++; - } - }*/ } else if (direction == DIRECTION.BOTTOM) { flagLoading = true; } @@ -625,7 +602,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. binding.recyclerView.setLayoutManager(mLayoutManager); binding.recyclerView.setAdapter(statusAdapter); - preloadSizeProvider = new ViewPreloadSizeProvider<>(); + ViewPreloadSizeProvider preloadSizeProvider = new ViewPreloadSizeProvider<>(); RecyclerViewPreloader preloader = new RecyclerViewPreloader<>( GlideApp.with(this), statusAdapter, preloadSizeProvider, PRELOAD_AHEAD_ITEMS); @@ -652,7 +629,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. flagLoading = true; binding.loadingNextElements.setVisibility(View.VISIBLE); router(DIRECTION.BOTTOM); - extraCalls = -1; } } else { binding.loadingNextElements.setVisibility(View.GONE); @@ -662,7 +638,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. flagLoading = true; binding.loadingNextElements.setVisibility(View.VISIBLE); router(DIRECTION.TOP); - extraCalls = -1; } } } @@ -724,7 +699,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. * * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ - private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) { + private void routeCommon(DIRECTION direction, boolean fetchingMissing) { if (binding == null || !isAdded() || getActivity() == null) { return; } @@ -881,9 +856,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } else { dealWithPagination(statusesCachedTop, DIRECTION.TOP, fetchingMissing, true); //Also check remotely to detect potential holes - if (fetchingMissing) { - getLiveStatus(direction, true, timelineParams, false); - } + getLiveStatus(direction, true, timelineParams, false); } }); @@ -929,34 +902,26 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } } - /** - * Router for timelines - * - * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll - */ - private void route(DIRECTION direction, boolean fetchingMissing) { - route(direction, fetchingMissing, null); - } /** * Router for timelines * * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ - private void route(DIRECTION direction, boolean fetchingMissing, Status statusToUpdate) { + private void route(DIRECTION direction, boolean fetchingMissing) { if (binding == null || !isAdded() || getActivity() == null) { return; } // --- HOME TIMELINE --- if (timelineType == Timeline.TimeLineEnum.HOME) { //for more visibility it's done through loadHomeStrategy method - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.LOCAL) { //LOCAL TIMELINE - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.PUBLIC) { //PUBLIC TIMELINE - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.BUBBLE) { //BUBBLE TIMELINE - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.REMOTE) { //REMOTE TIMELINE //NITTER TIMELINES if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) { @@ -1025,12 +990,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. }); } } else { //Other remote timelines - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } } else if (timelineType == Timeline.TimeLineEnum.LIST) { //LIST TIMELINE - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.TAG || timelineType == Timeline.TimeLineEnum.ART) { //TAG TIMELINE - routeCommon(direction, fetchingMissing, statusToUpdate); + routeCommon(direction, fetchingMissing); } else if (timelineType == Timeline.TimeLineEnum.ACCOUNT_TIMELINE) { //PROFILE TIMELINES String tempToken; String tempInstance; @@ -1198,26 +1163,26 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. } @Override - public void onClickMinId(String min_id, Status statusToUpdate) { + public void onClickMinId(String min_id) { //Fetch more has been pressed min_id_fetch_more = min_id; - route(DIRECTION.TOP, true, statusToUpdate); + route(DIRECTION.TOP, true); } @Override - public void onClickMaxId(String max_id, Status statusToUpdate) { + public void onClickMaxId(String max_id) { max_id_fetch_more = max_id; - route(DIRECTION.BOTTOM, true, statusToUpdate); + route(DIRECTION.BOTTOM, true); } @Override public void autoFetch(String min_id, String max_id, Status statusToUpdate) { if (scrollingUp) { min_id_fetch_more = min_id; - route(DIRECTION.TOP, true, statusToUpdate); + route(DIRECTION.TOP, true); } else { max_id_fetch_more = max_id; - route(DIRECTION.BOTTOM, true, statusToUpdate); + route(DIRECTION.BOTTOM, true); } }