From 76840ee9fc5fc54939803ad5f8e19da41ae74719 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 10 Feb 2020 22:15:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8D=A2=E6=BA=90=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/changesource/ChangeSourceDialog.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index 6edebd27a..4b129acea 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book @@ -93,6 +94,19 @@ class ChangeSourceDialog : DialogFragment(), recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.addItemDecoration(recycler_view.getVerticalDivider()) recycler_view.adapter = adapter + adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + if (positionStart == 0) { + recycler_view.scrollToPosition(0) + } + } + + override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { + if (toPosition == 0) { + recycler_view.scrollToPosition(0) + } + } + }) } private fun initSearchView() {