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) {
//Only StatusListFragments can display Status/Quotes
// Only StatusListFragments/NotificationsListFragments can display status with quotes
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
List<StatusDisplayItem> 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());
}
}
@ -792,9 +793,15 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
public void onToggleExpanded(Status status, boolean isForQuote, String itemID) {
status.textExpanded = !status.textExpanded;
List<TextStatusDisplayItem.Holder> 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<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);
HeaderStatusDisplayItem.Holder header=headers.size() > 1 && isForQuote ? headers.get(1) : headers.get(0);
if(header!=null) header.animateExpandToggle();