aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-15 20:25:40 -0700
committerAllan Wang <me@allanwang.ca>2017-06-15 20:25:40 -0700
commit15e77962960b043c657bd8ee1b719dbd41e636fb (patch)
treeab460d9c3622b297423414ec25580cadd229c764
parent5aba646c138116e0df0f33f071468c4e09a27e3b (diff)
downloadkau-15e77962960b043c657bd8ee1b719dbd41e636fb.tar.gz
kau-15e77962960b043c657bd8ee1b719dbd41e636fb.tar.bz2
kau-15e77962960b043c657bd8ee1b719dbd41e636fb.zip
Add changelog customizer
-rw-r--r--README.md1
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt7
2 files changed, 5 insertions, 3 deletions
diff --git a/README.md b/README.md
index 3aff56d..c8c9935 100644
--- a/README.md
+++ b/README.md
@@ -98,6 +98,7 @@ Create an xml resource with the following structure:
```
And show it with `context.showChangelog(@XmlRes xmlRes: Int)`
+There is an optional `customize` argument to modify the builder before showing the changelog.
As mentioned, blank items will be ignored, so feel free to create a bunch of empty lines to facilitate updating the items in the future.
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 b7b1586..77238f1 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
@@ -123,17 +123,18 @@ fun Context.resolveString(@AttrRes attr: Int, fallback: String = ""): String {
return if (theme.resolveAttribute(attr, v, true)) v.string.toString() else fallback
}
-fun Context.showChangelog(@XmlRes xmlRes: Int) {
+fun Context.showChangelog(@XmlRes xmlRes: Int, customize: MaterialDialog.Builder.() -> Unit = {}) {
val mHandler = Handler()
Thread(Runnable {
val items = parse(this, xmlRes)
mHandler.post(object : TimerTask() {
override fun run() {
- MaterialDialog.Builder(this@showChangelog)
+ val builder = MaterialDialog.Builder(this@showChangelog)
.title(R.string.kau_changelog)
.positiveText(R.string.kau_great)
.adapter(ChangelogAdapter(items), null)
- .show()
+ builder.customize()
+ builder.show()
}
})
}).start()