Permalink
Browse files

Bundle

  • Loading branch information...
VolodymyrLykhonis committed Jun 6, 2012
1 parent f1303b6 commit ea64b1b87ee72d188d0b4bd7c64f004baed641fb
Showing with 32 additions and 1 deletion.
  1. +5 −1 README.md
  2. +27 −0 src/com/vlad/android/kotlin/KotlinBundle.kt
View
@@ -143,8 +143,12 @@ See [Sample Activity](https://github.com/vladlichonos/kotlinAndroidLib/blob/mast
val future = executorService.submit<String?> { /* code here */ "Result" }
val future = executorService.submit<String?>("Result") { /* code here and result */ }
-* Wrap `Intent`, now easy to create new Intent without defining new variable:
+* Wrap `Intent`, now easy to create new `Intent` without defining new variable:
sendBroadcast(Intent() { setAction(Intent.ACTION_DEFAULT) })
startActivity(Intent(Intent.ACTION_VIEW) { setDataAndType(Uri.parse("http://example.com/audio.mp3"), "audio/mpeg") })
+* Wrap `Bundle`, now easy to create new `Bundle` without defining new variable:
+
+ Bundle { putString("result", "Some result!") }
+
@@ -0,0 +1,27 @@
+package com.vlad.android.kotlin
+
+import android.os.Bundle
+
+public inline fun Bundle(body: Bundle.() -> Unit): Bundle {
+ val bundle = Bundle()
+ bundle.body()
+ return bundle
+}
+
+public inline fun Bundle(loader: ClassLoader, body: Bundle.() -> Unit): Bundle {
+ val bundle = Bundle(loader)
+ bundle.body()
+ return bundle
+}
+
+public inline fun Bundle(capacity: Int, body: Bundle.() -> Unit): Bundle {
+ val bundle = Bundle(capacity)
+ bundle.body()
+ return bundle
+}
+
+public inline fun Bundle(b: Bundle?, body: Bundle.() -> Unit): Bundle {
+ val bundle = Bundle(b)
+ bundle.body()
+ return bundle
+}

0 comments on commit ea64b1b

Please sign in to comment.