From 886f0660712373563f6c51d92a83c41d2d32f954 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 3 Jan 2023 17:29:53 +0100 Subject: [PATCH] Fix issue #607 - Issue with fetchmore --- .../app/fedilab/android/activities/ComposeActivity.java | 4 +++- .../app/fedilab/android/client/entities/api/Status.java | 4 ++-- .../java/app/fedilab/android/ui/drawer/StatusAdapter.java | 1 - .../ui/fragment/timeline/FragmentMastodonTimeline.java | 7 +++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java index a97cd6da..849b28a9 100644 --- a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java @@ -634,7 +634,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana } if (statusReply.spoiler_text != null) { statusDraftList.get(0).spoiler_text = statusReply.spoiler_text; - statusDraftList.get(0).spoilerChecked = true; + if (statusReply.spoiler_text.trim().length() > 0) { + statusDraftList.get(0).spoilerChecked = true; + } } if (statusReply.language != null && !statusReply.language.isEmpty()) { statusDraftList.get(0).language = statusReply.language; diff --git a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java index 98ad50cd..fb3919a5 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java +++ b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java @@ -109,8 +109,8 @@ public class Status implements Serializable, Cloneable { public Attachment art_attachment; public boolean isExpended = false; public boolean isTruncated = true; - public boolean isFetchMore = false; - public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; + public transient boolean isFetchMore = false; + public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM; public boolean isChecked = false; public String translationContent; public boolean translationShown; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 5f2b9025..a7fc576c 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -2031,7 +2031,6 @@ public class StatusAdapter extends RecyclerView.Adapter drawerFetchMoreBinding.fetchMoreMin.setOnClickListener(v -> { status.isFetchMore = false; int position = holder.getBindingAdapterPosition(); - int position2 = getStatusPosition(statusList, status); adapter.notifyItemChanged(position); if (position < statusList.size() - 1) { String fromId; diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index 72c08c85..56080921 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -407,7 +407,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. binding.swipeContainer.setRefreshing(false); binding.loadingNextElements.setVisibility(View.GONE); flagLoading = false; - + int currentPosition = mLayoutManager.findFirstVisibleItemPosition(); if (timelineStatuses != null && fetched_statuses != null && fetched_statuses.statuses != null && fetched_statuses.statuses.size() > 0) { try { if (statusToUpdate != null) { @@ -470,7 +470,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. update.onUpdate(0, timelineType, slug); } if (direction == DIRECTION.TOP && fetchingMissing) { - binding.recyclerView.scrollToPosition(getPosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1)) + 1); + int newPosition = currentPosition + fetched_statuses.statuses.size() + 1; + if (newPosition < timelineStatuses.size()) { + binding.recyclerView.scrollToPosition(newPosition); + } } if (!fetchingMissing) { if (fetched_statuses.pagination.max_id == null) {