From 58f0c073575c005602ed29d01b413a124ecf9e66 Mon Sep 17 00:00:00 2001 From: sk Date: Sat, 9 Sep 2023 01:27:32 +0200 Subject: [PATCH] determine next display item using items list closes sk22#815 --- .../android/ui/displayitems/StatusDisplayItem.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index cdc663c6a..0dd08c548 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -397,10 +397,11 @@ public abstract class StatusDisplayItem{ } public Optional getDisplayItemOffset(int offset){ - int nextPos=getAbsoluteAdapterPosition() + offset; List displayItems=item.parentFragment.getDisplayItems(); - return displayItems.size() > nextPos - ? Optional.of(displayItems.get(nextPos)) + int thisPos=displayItems.indexOf(item); + int offsetPos=thisPos + offset; + return displayItems.size() > offsetPos && thisPos >= 0 && offsetPos >= 0 + ? Optional.of(displayItems.get(offsetPos)) : Optional.empty(); }