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 fc60dbd9..3c556efa 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 @@ -2141,7 +2141,6 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.fetchMoreContainerTop.setVisibility(View.GONE); status.isFetchMore = false; int position = holder.getBindingAdapterPosition(); - adapter.notifyItemChanged(position); String statusIdMin = null, statusIdMax; if (position < statusList.size() - 1) { if (status.positionFetchMore == Status.PositionFetchMore.TOP) { @@ -2614,32 +2613,53 @@ public class StatusAdapter extends RecyclerView.Adapter holder.bindingFilteredHide.dividerCard.setVisibility(View.GONE); } if (status.isFetchMore && fetchMoreCallBack != null) { - holder.bindingFilteredHide.layoutFetchMore.fetchMoreContainer.setVisibility(View.VISIBLE); - holder.bindingFilteredHide.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> { - status.isFetchMore = false; - notifyItemChanged(holder.getBindingAdapterPosition()); - if (holder.getBindingAdapterPosition() < statusList.size() - 1) { + boolean autofetch = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false); + if (!autofetch) { + holder.bindingFilteredHide.layoutFetchMore.fetchMoreContainer.setVisibility(View.VISIBLE); + holder.bindingFilteredHide.layoutFetchMore.fetchMoreMin.setOnClickListener(v -> { + status.isFetchMore = false; + notifyItemChanged(holder.getBindingAdapterPosition()); + if (holder.getBindingAdapterPosition() < statusList.size() - 1) { + String fromId; + if (status.positionFetchMore == Status.PositionFetchMore.TOP) { + fromId = statusList.get(holder.getBindingAdapterPosition() + 1).id; + } else { + fromId = status.id; + } + fetchMoreCallBack.onClickMinId(fromId, status); + } + }); + holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> { + //We hide the button + status.isFetchMore = false; + notifyItemChanged(holder.getBindingAdapterPosition()); String fromId; if (status.positionFetchMore == Status.PositionFetchMore.TOP) { - fromId = statusList.get(holder.getBindingAdapterPosition() + 1).id; + fromId = statusList.get(holder.getBindingAdapterPosition()).id; } else { - fromId = status.id; + fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id; } - fetchMoreCallBack.onClickMinId(fromId, status); - } - }); - holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> { - //We hide the button + fetchMoreCallBack.onClickMaxId(fromId, status); + + }); + } else { status.isFetchMore = false; - String fromId; - if (status.positionFetchMore == Status.PositionFetchMore.TOP) { - fromId = statusList.get(holder.getBindingAdapterPosition()).id; - } else { - fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id; + String minId = null, maxId; + if (holder.getBindingAdapterPosition() < statusList.size() - 1) { + if (status.positionFetchMore == Status.PositionFetchMore.TOP) { + minId = statusList.get(holder.getBindingAdapterPosition() + 1).id; + } else { + minId = status.id; + } } - fetchMoreCallBack.onClickMaxId(fromId, status); - notifyItemChanged(holder.getBindingAdapterPosition()); - }); + if (status.positionFetchMore == Status.PositionFetchMore.TOP) { + maxId = statusList.get(holder.getBindingAdapterPosition()).id; + } else { + maxId = statusList.get(holder.getBindingAdapterPosition() - 1).id; + } + fetchMoreCallBack.autoFetch(minId, maxId, status); + } + } else { holder.bindingFilteredHide.layoutFetchMore.fetchMoreContainer.setVisibility(View.GONE); } 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 12548023..bde61a95 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 @@ -507,8 +507,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. update.onUpdate(0, timelineType, slug); } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); - boolean autofetch = sharedpreferences.getBoolean(getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false); - if (direction == DIRECTION.TOP && fetchingMissing && !autofetch) { + if (direction == DIRECTION.TOP && fetchingMissing) { int position = getAbsolutePosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1)); if (position != -1) { binding.recyclerView.scrollToPosition(position + 1); @@ -657,7 +656,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - scrollingUp = dy > 0; + scrollingUp = dy < 0; if (requireActivity() instanceof BaseMainActivity) { if (dy < 0 && !((BaseMainActivity) requireActivity()).getFloatingVisibility()) ((BaseMainActivity) requireActivity()).manageFloatingButton(true);