Skip to content

Instantly share code, notes, and snippets.

@arifvn
Last active November 15, 2020 06:51
Show Gist options
  • Save arifvn/50003dbfe5dc4e181f2a3141f3e71c90 to your computer and use it in GitHub Desktop.
Save arifvn/50003dbfe5dc4e181f2a3141f3e71c90 to your computer and use it in GitHub Desktop.
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