فهرست منبع

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)
Jays2Kings 4 سال پیش
والد
کامیت
5f0493f1e5
1فایلهای تغییر یافته به همراه17 افزوده شده و 10 حذف شده
  1. 17 10
      app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt

+ 17 - 10
app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt

@@ -79,16 +79,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
         recycler.addOnScrollListener(
             object : RecyclerView.OnScrollListener() {
                 override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
-                    val position = 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)
-                        }
-                    }
+                    onScrolled()
 
                     if (dy < 0) {
                         val firstIndex = layoutManager.findFirstVisibleItemPosition()
@@ -243,11 +234,27 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
         val position = adapter.items.indexOf(page)
         if (position != -1) {
             recycler.scrollToPosition(position)
+            if (layoutManager.findLastEndVisibleItemPosition() == -1) {
+                onScrolled(position)
+            }
         } else {
             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].
      */