From b90607582aae6067916cc404cbcf753912af453a Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 7 Jul 2024 08:43:45 +0200 Subject: [PATCH 1/3] docs: keep comment inline with code changes --- .../joinmastodon/android/fragments/BaseStatusListFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 55e6a9883..fa4068edf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -718,7 +718,7 @@ public abstract class BaseStatusListFragment exten } if (startIndex!=-1 && endIndex!=-1) { - //Only StatusListFragments can display Status/Quotes + // Only StatusListFragments/NotificationsListFragments can display status with quotes assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment); List items=this.buildDisplayItems((T) parent); displayItems.subList(startIndex, endIndex+1).clear(); From ca4a1d461a7a55505920330c57f4919c8b0a3f7f Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 7 Jul 2024 08:44:20 +0200 Subject: [PATCH 2/3] fix(TextStatusDisplayItem): expand non-quoted texts Using the adapter to udpate the TextStatusDisplayItem does not work for non-quoted posts. Ref: https://github.com/sk22/megalodon/pull/956/commits/1832de3aab2cc868851f0add17a5be94700797ab --- .../android/fragments/BaseStatusListFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index fa4068edf..a0e4c08d5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -792,9 +792,15 @@ public abstract class BaseStatusListFragment exten public void onToggleExpanded(Status status, boolean isForQuote, String itemID) { status.textExpanded = !status.textExpanded; - List textItems = findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class); - TextStatusDisplayItem.Holder text = textItems.size() > 1 && isForQuote ? textItems.get(1) : textItems.get(0); - adapter.notifyItemChanged(text.getAbsoluteAdapterPosition()); + // TODO: simplify this to a single case + if(!isForQuote) + // using the adapter directly to update the item does not work for non-quoted texts + notifyItemChanged(itemID, TextStatusDisplayItem.class); + else{ + List textItems=findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class); + TextStatusDisplayItem.Holder text=textItems.size()>1 ? textItems.get(1) : textItems.get(0); + adapter.notifyItemChanged(text.getAbsoluteAdapterPosition()); + } List headers=findAllHoldersOfType(itemID, HeaderStatusDisplayItem.Holder.class); HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0); if(header!=null) header.animateExpandToggle(); From 9b1e79eba8bd09626400d0f7f14eb7659f809c5a Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 7 Jul 2024 08:50:57 +0200 Subject: [PATCH 3/3] fix(StatusDisplayItem/Quote): notify adapter separately Only notifying the adapter once could lead to cases where the quoting status was merged with or replaced by the quote status. Separately notifying it seems to trigger the issue less often. --- .../joinmastodon/android/fragments/BaseStatusListFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index a0e4c08d5..e6af4d78b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -722,10 +722,11 @@ public abstract class BaseStatusListFragment exten assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment); List items=this.buildDisplayItems((T) parent); displayItems.subList(startIndex, endIndex+1).clear(); + adapter.notifyItemRangeRemoved(startIndex, endIndex+1); boolean isEmpty=displayItems.isEmpty(); displayItems.addAll(startIndex, items); if(!isEmpty) - adapter.notifyItemRangeChanged(startIndex, items.size()); + adapter.notifyItemRangeInserted(startIndex, items.size()); } }