From 55ad624209b5e9c28a28f4ea38381d79cadd08aa Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Wed, 17 Jul 2024 16:10:44 -0300 Subject: [PATCH] fix(unofficial-quote-toots): try and fix the adapter madness I ended up adapting the poll items logic for this. I hope this is stable enough. --- .../fragments/BaseStatusListFragment.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 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 168154ade..4aaa6b3b6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -717,17 +717,18 @@ public abstract class BaseStatusListFragment exten } } - if (startIndex!=-1 && endIndex!=-1) { - // Only StatusListFragments/NotificationsListFragments can display status with quotes - assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment); - List items=this.buildDisplayItems((T) parent); - int itemCount = displayItems.subList(startIndex, endIndex+1).size()-1; - displayItems.subList(startIndex, endIndex+1).clear(); - adapter.notifyItemRangeChanged(startIndex, itemCount); - displayItems.addAll(startIndex, items); - if(!displayItems.isEmpty()) - adapter.notifyItemRangeChanged(startIndex, items.size()-1); - } + if (startIndex==-1 && endIndex==-1) + return; + + // Only StatusListFragments/NotificationsListFragments can display status with quotes + assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment); + List oldItems = displayItems.subList(startIndex, endIndex+1); + List newItems=this.buildDisplayItems((T) parent); + int prevSize=oldItems.size(); + oldItems.clear(); + displayItems.addAll(startIndex, newItems); + adapter.notifyItemRangeRemoved(startIndex, prevSize); + adapter.notifyItemRangeInserted(startIndex, newItems.size()); } public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) {