Fix random scrolling when bookmarking a chapter
This commit is contained in:
parent
e8100fc958
commit
cccf956fae
@ -49,18 +49,20 @@ class ReaderChapterDialog(private val activity: ReaderActivity) : ReaderChapterA
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun refreshList() {
|
||||
private fun refreshList(scroll: Boolean = true) {
|
||||
val chapters = presenter.getChapters(activity)
|
||||
.sortedWith(getChapterSort(presenter.manga!!))
|
||||
|
||||
adapter?.clear()
|
||||
adapter?.updateDataSet(chapters)
|
||||
|
||||
if (scroll) {
|
||||
(binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||
adapter?.getGlobalPositionOf(chapters.find { it.isCurrent }) ?: 0,
|
||||
(binding.chapterRecycler.height / 2).dpToPx
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
adapter = null
|
||||
@ -68,6 +70,6 @@ class ReaderChapterDialog(private val activity: ReaderActivity) : ReaderChapterA
|
||||
|
||||
override fun bookmarkChapter(chapter: Chapter) {
|
||||
presenter.toggleBookmark(chapter)
|
||||
refreshList()
|
||||
refreshList(scroll = false)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user