فهرست منبع

Fix NullPointerException from longPress_Paste()

cooperku_kdanmobile 4 سال پیش
والد
کامیت
702e8428f9
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      src/main/java/com/kdanmobile/reader/screen/contextmenu/MyKMPDFContextMenuCallback.kt

+ 6 - 4
src/main/java/com/kdanmobile/reader/screen/contextmenu/MyKMPDFContextMenuCallback.kt

@@ -335,10 +335,12 @@ open class MyKMPDFContextMenuCallback(private val kmpdfFactory: KMPDFFactory?) :
             btnPaste.setTextColor(ContextCompat.getColor(context, R.color.reader_contextMenu_text_disabled))
             btnPaste.setTextColor(ContextCompat.getColor(context, R.color.reader_contextMenu_text_disabled))
         }
         }
         btnPaste.setOnClickListener {
         btnPaste.setOnClickListener {
-            if (clipboardManager.hasPrimaryClip()) {
-                val kmpdfLongPressCreateAnnotController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.LONGCLICK) as KMPDFLongPressCreateAnnotController?
-                kmpdfLongPressCreateAnnotController?.longPress_Paste()
-                onLongPress()
+            if (clipboardManager.hasPrimaryClip() && !(clipboardManager.primaryClip?.getItemAt(0)?.text?.toString()).isNullOrEmpty()) {
+                try {
+                    val kmpdfLongPressCreateAnnotController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.LONGCLICK) as KMPDFLongPressCreateAnnotController?
+                    kmpdfLongPressCreateAnnotController?.longPress_Paste()
+                    onLongPress()
+                } catch (e: Exception) {}
             }
             }
             dismissPopupWindow()
             dismissPopupWindow()
         }
         }