Last active
February 20, 2018 13:34
-
-
Save pandulapeter/925e8d088ebdd0e17ad71c000508dc69 to your computer and use it in GitHub Desktop.
BundleDelegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class BundleDelegate<T>(protected val key: kotlin.String) : ReadWriteProperty<Bundle, T> { | |
class Int(key: kotlin.String) : BundleDelegate<kotlin.Int>(key) { | |
override fun getValue(thisRef: Bundle, property: KProperty<*>) = thisRef.getInt(key) | |
override fun setValue(thisRef: Bundle, property: KProperty<*>, value: kotlin.Int) = thisRef.putInt(key, value) | |
} | |
class String(key: kotlin.String) : BundleDelegate<kotlin.String>(key) { | |
override fun getValue(thisRef: Bundle, property: KProperty<*>) = thisRef.getString(key) | |
override fun setValue(thisRef: Bundle, property: KProperty<*>, value: kotlin.String) = thisRef.putString(key, value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment