aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt
new file mode 100644
index 0000000..2ef1232
--- /dev/null
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt
@@ -0,0 +1,24 @@
+package ca.allanwang.kau.utils
+
+import android.os.Bundle
+import android.support.v4.app.Fragment
+
+/**
+ * Created by Allan Wang on 2017-05-29.
+ */
+
+private fun Fragment.bundle(): Bundle {
+ if (this.arguments == null)
+ this.arguments = Bundle()
+ return this.arguments
+}
+
+fun <T : Fragment> T.putString(key: String, value: String): T {
+ this.bundle().putString(key, value)
+ return this
+}
+
+fun <T : Fragment> T.putInt(key: String, value: Int): T {
+ this.bundle().putInt(key, value)
+ return this
+} \ No newline at end of file