Skip to content

Commit 7960a78

Browse files
committedJul 10, 2024
fix(BaseStatusListFragment): save scroll position when adding quote
Partially fixes an issue, where the recylcerview would be reset back to the top when adding a quote. With this it only lags/stutters.
1 parent 803e66f commit 7960a78

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import androidx.annotation.NonNull;
2020
import androidx.annotation.Nullable;
21+
import androidx.recyclerview.widget.LinearLayoutManager;
2122
import androidx.recyclerview.widget.RecyclerView;
2223

2324
import org.joinmastodon.android.E;
@@ -718,6 +719,7 @@ public void updateStatusWithQuote(DisplayItemsParent parent) {
718719
}
719720

720721
if (startIndex!=-1 && endIndex!=-1) {
722+
int scrollPosition = ((LinearLayoutManager) list.getLayoutManager()).findFirstVisibleItemPosition();
721723
// Only StatusListFragments/NotificationsListFragments can display status with quotes
722724
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
723725
List<StatusDisplayItem> items=this.buildDisplayItems((T) parent);
@@ -727,6 +729,7 @@ public void updateStatusWithQuote(DisplayItemsParent parent) {
727729
displayItems.addAll(startIndex, items);
728730
if(!isEmpty)
729731
adapter.notifyItemRangeInserted(startIndex, items.size());
732+
list.scrollToPosition(scrollPosition);
730733
}
731734
}
732735

0 commit comments

Comments
 (0)