Quellcode durchsuchen

Merge branch '132-close-btn-hook' into 'master'

Resolve "增加 close btn hook"

Closes #132

See merge request kdanandroid/pdf/pdfreaderreadermodule!64
Wayne Huang vor 4 Jahren
Ursprung
Commit
071858f320
1 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 9 1
      src/main/java/com/kdanmobile/reader/ReaderActivity.kt

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

@@ -74,6 +74,10 @@ abstract class ReaderActivity :
     abstract fun providePdfThumbDialogFragment(): PdfThumbDialogFragment
     abstract fun isIBonPrintEnabled(): Boolean
 
+    /**
+     * return true = intercept, false = not intercept (same as touch event)
+     */
+    open fun onClickCloseButton(): Boolean { return false }
     open fun isBottomBarKdanCloudBtnVisible(): Boolean { return true }
     open fun insertToRecentDocumentList(filename: String) {}
     open fun saveCurrentPageIndex(filename: String, currentPage: Int) {}
@@ -701,7 +705,11 @@ abstract class ReaderActivity :
     }
 
     private fun setupToolbar() {
-        toolbar_readerActivity.setNavigationOnClickListener { finish() }
+        toolbar_readerActivity.setNavigationOnClickListener {
+            if (!onClickCloseButton()) {
+                finish()
+            }
+        }
         toolbar_readerActivity.setOnMenuItemClickListener {
             when (it.itemId) {
                 R.id.item_reader_bookmark -> onClickBookmark()