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.
This commit is contained in:
LucasGGamerM
2024-07-17 16:10:44 -03:00
parent 18079454a9
commit 55ad624209

View File

@@ -717,17 +717,18 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
} }
} }
if (startIndex!=-1 && endIndex!=-1) { if (startIndex==-1 && endIndex==-1)
return;
// Only StatusListFragments/NotificationsListFragments can display status with quotes // Only StatusListFragments/NotificationsListFragments can display status with quotes
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment); assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
List<StatusDisplayItem> items=this.buildDisplayItems((T) parent); List<StatusDisplayItem> oldItems = displayItems.subList(startIndex, endIndex+1);
int itemCount = displayItems.subList(startIndex, endIndex+1).size()-1; List<StatusDisplayItem> newItems=this.buildDisplayItems((T) parent);
displayItems.subList(startIndex, endIndex+1).clear(); int prevSize=oldItems.size();
adapter.notifyItemRangeChanged(startIndex, itemCount); oldItems.clear();
displayItems.addAll(startIndex, items); displayItems.addAll(startIndex, newItems);
if(!displayItems.isEmpty()) adapter.notifyItemRangeRemoved(startIndex, prevSize);
adapter.notifyItemRangeChanged(startIndex, items.size()-1); adapter.notifyItemRangeInserted(startIndex, newItems.size());
}
} }
public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) { public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) {