aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-14 16:41:32 -0700
committerAllan Wang <me@allanwang.ca>2017-06-14 16:41:32 -0700
commit4b612ec2649c46e71c0b839ceff5b9ca50b87f6e (patch)
tree3f4452b380e70f8ef3549e1dbaba9f062631fa0b
parentda6ea537adb2cb1abf7fe63187398615871670c7 (diff)
downloadkau-4b612ec2649c46e71c0b839ceff5b9ca50b87f6e.tar.gz
kau-4b612ec2649c46e71c0b839ceff5b9ca50b87f6e.tar.bz2
kau-4b612ec2649c46e71c0b839ceff5b9ca50b87f6e.zip
Add build and show to MD
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt10
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt3
2 files changed, 8 insertions, 5 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
index f5361c3..eeaa93c 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
@@ -135,10 +135,14 @@ fun Context.showChangelog(@XmlRes xmlRes: Int) {
/**
* Wrapper function for the MaterialDialog builder
- * Must end with build() to return the dialog
- * Don't forget to call show() on the result to display the dialog
+ * There is no need to call build() or show() as those are done by default
*/
-fun Context.materialDialog(action: MaterialDialog.Builder.() -> MaterialDialog): MaterialDialog = MaterialDialog.Builder(this).action()
+fun Context.materialDialog(action: MaterialDialog.Builder.() -> Unit): MaterialDialog {
+ val builder = MaterialDialog.Builder(this)
+ builder.action()
+ builder.build()
+ return builder.show()
+}
val Context.isNetworkAvailable: Boolean
get() {
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index b8ba393..544f349 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -93,8 +93,7 @@ class MainActivity : KPrefActivity() {
reloadByTitle(R.string.text)
})
inputRange(0, 20)
- build()
- }.show()
+ }
true
}
})