瀏覽代碼

Unnecessary null checks

Aidan Follestad 6 年之前
父節點
當前提交
daa03429db

+ 2 - 3
files/src/main/java/com/afollestad/materialdialogs/files/DialogFileChooserExt.kt

@@ -44,7 +44,7 @@ typealias FileCallback = ((dialog: MaterialDialog, file: File) -> Unit)?
 /** Gets the selected file for the current file chooser dialog. */
 @CheckResult
 fun MaterialDialog.selectedFile(): File? {
-  val customView = getCustomView() ?: return null
+  val customView = getCustomView()
   val list: DialogRecyclerView = customView.findViewById(R.id.list)
   return (list.adapter as? FileChooserAdapter)?.selectedFile
 }
@@ -143,8 +143,7 @@ internal fun MaterialDialog.showNewFolderCreator(
       onCreation()
     }
   }
-  dialog.getInputField()
-      ?.blockReservedCharacters()
+  dialog.getInputField().blockReservedCharacters()
 }
 
 private fun EditText.blockReservedCharacters() {

+ 1 - 1
files/src/main/java/com/afollestad/materialdialogs/files/DialogFolderChooserExt.kt

@@ -89,7 +89,7 @@ fun MaterialDialog.folderChooser(
   customView(R.layout.md_file_chooser_base, noVerticalPadding = true)
   setActionButtonEnabled(POSITIVE, false)
 
-  val customView = getCustomView() ?: return this
+  val customView = getCustomView()
   val list: DialogRecyclerView = customView.findViewById(R.id.list)
   val emptyText: TextView = customView.findViewById(R.id.empty_text)
   emptyText.setText(emptyTextRes)