sindrenm
07/27/2018, 12:08 PMfind
extension on View
that just encapsulates lazily finding the view through `lazy`:
fun <T : View> View.find(id: Int) = lazy(LazyThreadSafetyMode.NONE) { findViewById<T>(id) }
Usage:
<Button id="@+id/some_button" />
class SomeView : View {
private val someButton: Button by find(R.id.some_button)
}
rkeazor
07/27/2018, 1:42 PMgildor
07/28/2018, 5:57 AM