Procházet zdrojové kódy

assertOneSet should include method name

Aidan Follestad před 6 roky
rodič
revize
a9dd8e2908

+ 6 - 5
core/src/main/java/com/afollestad/materialdialogs/MaterialDialog.kt

@@ -41,11 +41,12 @@ import com.afollestad.materialdialogs.utils.setDefaults
 import com.afollestad.materialdialogs.utils.setWindowConstraints
 
 internal fun assertOneSet(
-  a: Int?,
-  b: Any?
+  method: String,
+  b: Any?,
+  a: Int?
 ) {
   if ((a == null || a == 0) && b == null) {
-    throw IllegalArgumentException("You must specify a resource ID or literal value.")
+    throw IllegalArgumentException("$method: You must specify a resource ID or literal value")
   }
 }
 
@@ -110,7 +111,7 @@ class MaterialDialog(
     @DrawableRes res: Int? = null,
     drawable: Drawable? = null
   ): MaterialDialog {
-    assertOneSet(res, drawable)
+    assertOneSet("icon", drawable, res)
     populateIcon(
         view.titleLayout.iconView,
         iconRes = res,
@@ -130,7 +131,7 @@ class MaterialDialog(
     @StringRes res: Int? = null,
     text: String? = null
   ): MaterialDialog {
-    assertOneSet(res, text)
+    assertOneSet("title", text, res)
     populateText(
         view.titleLayout.titleView,
         textRes = res,

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/checkbox/DialogCheckboxExt.kt

@@ -39,7 +39,7 @@ fun MaterialDialog.checkBoxPrompt(
   isCheckedDefault: Boolean = false,
   onToggle: BooleanCallback
 ): MaterialDialog {
-  assertOneSet(res, text)
+  assertOneSet("checkBoxPrompt", text, res)
   view.buttonsLayout.checkBoxPrompt.apply {
     this.visibility = View.VISIBLE
     this.text = text ?: getString(res)

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/customview/DialogCustomViewExt.kt

@@ -44,7 +44,7 @@ fun MaterialDialog.customView(
             "(e.g. list, message, input, etc.)"
     )
   }
-  assertOneSet(viewRes, view)
+  assertOneSet("customView", view, viewRes)
   if (scrollable || this.contentScrollViewFrame != null) {
     addContentScrollView()
     this.contentCustomView = view ?: inflate(viewRes!!, this.contentScrollViewFrame!!)

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/list/DialogListExt.kt

@@ -62,7 +62,7 @@ fun MaterialDialog.listItems(
   waitForPositiveButton: Boolean = true,
   selection: ItemListener = null
 ): MaterialDialog {
-  assertOneSet(res, items)
+  assertOneSet("listItems", items, res)
   val array = items ?: getStringArray(res)?.toList()
   val adapter = getListAdapter()
 

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/list/DialogMultiChoiceExt.kt

@@ -47,7 +47,7 @@ fun MaterialDialog.listItemsMultiChoice(
     return this
   }
 
-  assertOneSet(res, items)
+  assertOneSet("listItemsMultiChoice", items, res)
   setActionButtonEnabled(POSITIVE, initialSelection.isNotEmpty())
   return customListAdapter(
       MultiChoiceDialogAdapter(

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/list/DialogSingleChoiceExt.kt

@@ -47,7 +47,7 @@ fun MaterialDialog.listItemsSingleChoice(
     return this
   }
 
-  assertOneSet(res, items)
+  assertOneSet("listItemsSingleChoice", items, res)
   setActionButtonEnabled(POSITIVE, initialSelection > -1)
   return customListAdapter(
       SingleChoiceDialogAdapter(

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/utils/DialogExt.kt

@@ -90,7 +90,7 @@ internal fun MaterialDialog.addContentMessageView(@StringRes res: Int?, text: Ch
       this.textViewMessage?.typeface = this.bodyFont
     }
   }
-  assertOneSet(res, text)
+  assertOneSet("message", text, res)
   this.textViewMessage!!.text = text ?: getString(res)
 }
 

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/utils/DimensExt.kt

@@ -12,7 +12,7 @@ internal fun MaterialDialog.dimen(
   @AttrRes attr: Int? = null,
   fallback: Float = windowContext.resources.getDimension(R.dimen.md_dialog_default_corner_radius)
 ): Float {
-  assertOneSet(res, attr)
+  assertOneSet("dimen", attr, res)
   if (res != null) {
     return windowContext.resources.getDimension(res)
   }

+ 1 - 1
core/src/main/java/com/afollestad/materialdialogs/utils/FontExt.kt

@@ -13,7 +13,7 @@ internal fun MaterialDialog.font(
   @FontRes res: Int? = null,
   @AttrRes attr: Int? = null
 ): Typeface? {
-  assertOneSet(res, attr)
+  assertOneSet("font", attr, res)
   if (res != null) {
     return ResourcesCompat.getFont(windowContext, res)
   }