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