Twidere-App-Android-Twitter.../twidere/src/main/kotlin/org/mariotaku/ktextension/BundleExtensions.kt

38 lines
820 B
Kotlin
Raw Normal View History

2016-08-30 14:23:59 +02:00
package org.mariotaku.ktextension
import android.os.Bundle
import android.os.Parcelable
/**
* Created by mariotaku on 16/8/18.
*/
inline fun Bundle(action: Bundle.() -> Unit): Bundle {
val bundle = Bundle()
action(bundle)
return bundle
}
operator fun Bundle.set(key: String, value: Boolean) {
return putBoolean(key, value)
}
operator fun Bundle.set(key: String, value: Int) {
return putInt(key, value)
}
operator fun Bundle.set(key: String, value: Long) {
return putLong(key, value)
}
operator fun Bundle.set(key: String, value: String) {
return putString(key, value)
}
operator fun Bundle.set(key: String, value: Parcelable?) {
return putParcelable(key, value)
}
operator fun Bundle.set(key: String, value: Array<out Parcelable>?) {
return putParcelableArray(key, value)
}