Skip to content

Commit

Permalink
fix(unofficial-quote-toots): try and fix the adapter madness
Browse files Browse the repository at this point in the history
I ended up adapting the poll items logic for this. I hope this is stable enough.
  • Loading branch information
LucasGGamerM committed Jul 17, 2024
1 parent 1807945 commit 55ad624
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,17 +717,18 @@ public void updateStatusWithQuote(DisplayItemsParent parent) {
}
}

if (startIndex!=-1 && endIndex!=-1) {
// Only StatusListFragments/NotificationsListFragments can display status with quotes
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
List<StatusDisplayItem> 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<StatusDisplayItem> oldItems = displayItems.subList(startIndex, endIndex+1);
List<StatusDisplayItem> 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) {
Expand Down

0 comments on commit 55ad624

Please sign in to comment.