fix: 换源界面

pull/95/head
kunfei 5 years ago
parent 9aa443f70d
commit 76840ee9fc
  1. 14
      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.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -93,6 +94,19 @@ class ChangeSourceDialog : DialogFragment(),
recycler_view.layoutManager = LinearLayoutManager(context) recycler_view.layoutManager = LinearLayoutManager(context)
recycler_view.addItemDecoration(recycler_view.getVerticalDivider()) recycler_view.addItemDecoration(recycler_view.getVerticalDivider())
recycler_view.adapter = adapter 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() { private fun initSearchView() {

Loading…
Cancel
Save