Browse Source

Add comments

cooperku_kdanmobile 5 years ago
parent
commit
6afb88b318
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/main/java/com/kdanmobile/reader/ReaderActivity.kt

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

@@ -113,11 +113,13 @@ abstract class ReaderActivity : KdanBaseActivity(), ReaderSettingListener, PdfTh
         }
 
     private val viewModel: ReaderViewModel by viewModel {
-        filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
+        val filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
         if (!filePath.isNullOrEmpty()) {
             insertToRecentDocumentList(filePath as String)
         }
         val uri = if (!filePath.isNullOrEmpty()) Uri.parse(Uri.encode(filePath)) else null
+        // The URI may be null in some special case.
+        // Just use Uri.EMPTY and show an alert dialog in onCreate() when the uri is null.
         parametersOf(uri ?: Uri.EMPTY)
     }
     private var isShowPasswordActivity = false
@@ -158,6 +160,7 @@ abstract class ReaderActivity : KdanBaseActivity(), ReaderSettingListener, PdfTh
         setContentView(R.layout.activity_reader)
         setSupportActionBar(toolbar_readerActivity)
         isShowPasswordActivity = savedInstanceState?.getBoolean(KEY_IS_PASSWORD_ACTIVITY_SHOWING) ?: false
+        // Get file path to determine the opening file is pdf or not
         filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
 
         val displayMetrics = DisplayMetrics()