From 287abcafc09aabe00d8dd3261978044e4363a8e3 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Tue, 5 Feb 2019 18:48:13 +0000 Subject: [PATCH] Add adapter listener to set the list to the top when inserting new items --- app/src/main/java/com/readrops/app/MainActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/readrops/app/MainActivity.java b/app/src/main/java/com/readrops/app/MainActivity.java index 3141bfe6..9ef356f7 100644 --- a/app/src/main/java/com/readrops/app/MainActivity.java +++ b/app/src/main/java/com/readrops/app/MainActivity.java @@ -168,7 +168,12 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S } }).attachToRecyclerView(recyclerView); - + adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { + @Override + public void onItemRangeInserted(int positionStart, int itemCount) { + recyclerView.scrollToPosition(0); + } + }); } private void updateList() {