瀏覽代碼

Minor cleanup

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

+ 2 - 2
color/src/main/java/com/afollestad/materialdialogs/color/DialogColorChooserExt.kt

@@ -198,7 +198,7 @@ private fun MaterialDialog.setupGridLayout(
       initialSelection = initialSelection,
       waitForPositiveButton = waitForPositiveButton,
       callback = selection,
-      enableARGBButton = allowCustomArgb && isLandscape(context)
+      enableARGBButton = allowCustomArgb && context.isLandscape()
   )
   gridRecyclerView.adapter = adapter
 }
@@ -217,7 +217,7 @@ private fun MaterialDialog.setupCustomPage(
     viewSet.setColorAlpha(ALPHA_SOLID)
   }
 
-  val landscape = isLandscape(context)
+  val landscape = context.isLandscape()
   if (!supportCustomAlpha) {
     viewSet.alphaLabel.changeHeight(0)
     viewSet.alphaSeeker.changeHeight(0)

+ 4 - 3
core/src/main/java/com/afollestad/materialdialogs/utils/MDUtil.kt

@@ -140,8 +140,8 @@ object MDUtil {
     return context.resources.getDimensionPixelSize(res)
   }
 
-  @RestrictTo(LIBRARY_GROUP) fun isLandscape(context: Context) =
-    context.resources.configuration.orientation == ORIENTATION_LANDSCAPE
+  @RestrictTo(LIBRARY_GROUP) fun Context.isLandscape() =
+    resources.configuration.orientation == ORIENTATION_LANDSCAPE
 
   @RestrictTo(LIBRARY_GROUP) fun EditText.textChanged(callback: (CharSequence) -> Unit) {
     this.addTextChangedListener(object : TextWatcher {
@@ -173,7 +173,8 @@ object MDUtil {
     }
   }
 
-  @RestrictTo(LIBRARY_GROUP) fun Int?.ifNotZero(block: (value: Int) -> Unit) {
+  @RestrictTo(LIBRARY_GROUP)
+  inline fun Int?.ifNotZero(block: (value: Int) -> Unit) {
     if (this != null && this != 0) {
       block(this)
     }