Merge pull request #457 from FineFindus/fix/more-fixes

fix(quotes): more fixes
This commit is contained in:
LucasGGamerM 2024-07-07 09:00:30 -03:00 committed by GitHub
commit ed22d3b4ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -718,14 +718,15 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
} }
if (startIndex!=-1 && endIndex!=-1) { 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); assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
List<StatusDisplayItem> items=this.buildDisplayItems((T) parent); List<StatusDisplayItem> items=this.buildDisplayItems((T) parent);
displayItems.subList(startIndex, endIndex+1).clear(); displayItems.subList(startIndex, endIndex+1).clear();
adapter.notifyItemRangeRemoved(startIndex, endIndex+1);
boolean isEmpty=displayItems.isEmpty(); boolean isEmpty=displayItems.isEmpty();
displayItems.addAll(startIndex, items); displayItems.addAll(startIndex, items);
if(!isEmpty) if(!isEmpty)
adapter.notifyItemRangeChanged(startIndex, items.size()); adapter.notifyItemRangeInserted(startIndex, items.size());
} }
} }
@ -792,9 +793,15 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
public void onToggleExpanded(Status status, boolean isForQuote, String itemID) { public void onToggleExpanded(Status status, boolean isForQuote, String itemID) {
status.textExpanded = !status.textExpanded; status.textExpanded = !status.textExpanded;
List<TextStatusDisplayItem.Holder> textItems = findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class); // TODO: simplify this to a single case
TextStatusDisplayItem.Holder text = textItems.size() > 1 && isForQuote ? textItems.get(1) : textItems.get(0); if(!isForQuote)
adapter.notifyItemChanged(text.getAbsoluteAdapterPosition()); // using the adapter directly to update the item does not work for non-quoted texts
notifyItemChanged(itemID, TextStatusDisplayItem.class);
else{
List<TextStatusDisplayItem.Holder> textItems=findAllHoldersOfType(itemID, TextStatusDisplayItem.Holder.class);
TextStatusDisplayItem.Holder text=textItems.size()>1 ? textItems.get(1) : textItems.get(0);
adapter.notifyItemChanged(text.getAbsoluteAdapterPosition());
}
List<HeaderStatusDisplayItem.Holder> headers=findAllHoldersOfType(itemID, HeaderStatusDisplayItem.Holder.class); List<HeaderStatusDisplayItem.Holder> headers=findAllHoldersOfType(itemID, HeaderStatusDisplayItem.Holder.class);
HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0); HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0);
if(header!=null) header.animateExpandToggle(); if(header!=null) header.animateExpandToggle();