3 次代碼提交 071858f320 ... 5033b31495

作者 SHA1 備註 提交日期
  Wayne Huang 5033b31495 Merge branch '133-' into 'master' 4 年之前
  Wayne Huang 164c67df7e Rename argument 4 年之前
  cooperku_kdanmobile e4f6fde0f6 Fix wrong page status after removing additional pages 4 年之前

+ 2 - 1
src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -545,7 +545,8 @@ abstract class ReaderActivity :
     fun removeAdditionalPages() {
         if (additionalPageManager.displayStrategyType == AdditionalPageDisplayStrategyType.HIDE) return
         val handler = viewModel.pdfInfoHandler
-        val pageIndex = currentPageIndex
+        val pageIndex = additionalPageManager.pageConverter.convertToRawPageIndex(currentPageIndex, true)
+                .coerceAtMost(pageCount - 1)
         additionalPageManager.displayStrategyType = AdditionalPageDisplayStrategyType.HIDE
         viewModel.getReaderView()?.refresh(true)
         handler.goToCurrentPage(pageIndex)

+ 2 - 3
src/main/java/com/kdanmobile/reader/additionalpage/AdditionalPageConverter.kt

@@ -60,8 +60,8 @@ class AdditionalPageConverter(
     /**
      * 頁碼轉換,計算第pageIndex頁刪除額外頁面後是原始文件的第幾頁
      */
-    fun convertToRawPageIndex(pageIndex: Int): Int {
-        if (!shouldApplyAdditionalPage()) return pageIndex
+    fun convertToRawPageIndex(pageIndex: Int, forceIncludeAdditionalPage: Boolean = false): Int {
+        if (!forceIncludeAdditionalPage && !shouldApplyAdditionalPage()) return pageIndex
         if (pageIndex < firstAdditionalPageIndex) return pageIndex
         return (pageIndex * additionalPageInterval + firstAdditionalPageIndex) / (additionalPageInterval + 1)
     }
@@ -98,7 +98,6 @@ class AdditionalPageConverter(
     /**
      * 是否套用額外頁面(非垂直閱覽模式則不套用)
      */
-
     private fun shouldApplyAdditionalPage(): Boolean {
         return isAdditionalPageEnabled.invoke() && isVerticalContinuesViewMode()
     }