Last active
November 15, 2020 06:51
-
-
Save arifvn/50003dbfe5dc4e181f2a3141f3e71c90 to your computer and use it in GitHub Desktop.
This file contains 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
class ViewDelegate( | |
private val viewId: Int | |
): ReadOnlyProperty<AppCompatActivity, String> { | |
private var result: String? = null | |
override fun getValue(thisRef: AppCompatActivity, property: KProperty<*>): String = | |
result ?: thisRef.findViewById(viewId).also { result = it } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment