Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class StringDelegate : ReadOnlyPropery<ContextProvider, String> {
private val stringRes: Int
private var string: String? = null
constructor(@StringRes stringRes: Int) {
this.stringRes = stringRes
override fun getValue(ref: ContextProvider, property: KProperty<*>): String {
if (string == null) {
string = ref.provideContext().getString(stringRes)
return string ?: throw IllegalStateException()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.