mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Fix webtoon mode not calling OnPageSelected in some cases (in upstream too)
This fix isn't 100% tested, but like 80%. @arkon if you're reading this, this issue is happening up stream too. I can make a issue for it in the repo but haven't checked if it happens there: Steps: Get Cubari source, search "cubari:imgur/3iOqiIy" change to continuous vertical, crop borders. Then back out and open the chapter again. onPageSelected isn't called because recycler position is -1. Regardless of the 4 pages you should be on also fyi just a slight scroll fixes this issue but still (cherry picked from commit 88fd6e5c9897d4a528f93dd02cfa2a4c644a799d)
This commit is contained in:
parent
c749e50bec
commit
5f0493f1e5
@ -79,16 +79,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||||||
recycler.addOnScrollListener(
|
recycler.addOnScrollListener(
|
||||||
object : RecyclerView.OnScrollListener() {
|
object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
val position = layoutManager.findLastEndVisibleItemPosition()
|
onScrolled()
|
||||||
val item = adapter.items.getOrNull(position)
|
|
||||||
val allowPreload = checkAllowPreload(item as? ReaderPage)
|
|
||||||
if (item != null && currentPage != item) {
|
|
||||||
currentPage = item
|
|
||||||
when (item) {
|
|
||||||
is ReaderPage -> onPageSelected(item, allowPreload)
|
|
||||||
is ChapterTransition -> onTransitionSelected(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dy < 0) {
|
if (dy < 0) {
|
||||||
val firstIndex = layoutManager.findFirstVisibleItemPosition()
|
val firstIndex = layoutManager.findFirstVisibleItemPosition()
|
||||||
@ -243,11 +234,27 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||||||
val position = adapter.items.indexOf(page)
|
val position = adapter.items.indexOf(page)
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
recycler.scrollToPosition(position)
|
recycler.scrollToPosition(position)
|
||||||
|
if (layoutManager.findLastEndVisibleItemPosition() == -1) {
|
||||||
|
onScrolled(position)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Timber.d("Page $page not found in adapter")
|
Timber.d("Page $page not found in adapter")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onScrolled(pos: Int? = null) {
|
||||||
|
val position = pos ?: layoutManager.findLastEndVisibleItemPosition()
|
||||||
|
val item = adapter.items.getOrNull(position)
|
||||||
|
val allowPreload = checkAllowPreload(item as? ReaderPage)
|
||||||
|
if (item != null && currentPage != item) {
|
||||||
|
currentPage = item
|
||||||
|
when (item) {
|
||||||
|
is ReaderPage -> onPageSelected(item, allowPreload)
|
||||||
|
is ChapterTransition -> onTransitionSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls up by [scrollDistance].
|
* Scrolls up by [scrollDistance].
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user