if usting KOTTERKNIFE in fragment, `private val re...
# android
u
if usting KOTTERKNIFE in fragment,
private val registerTextView: TextView by bindView(R.id.registerTextView)
g
Correct. There is no support of view lifecycle. But looks that it’s possible to do, but before Lifecycle for views released it required to use custom fragment that exposes view lifecycle callbacks
u
Well that sucks, any way around that? nullable vars? then ReadOnlyProperty doesnt work. So it has to be a new feature of the library?
g
Yes, it's completely new feature, actually requires rewriting of fragment integration implementation. Would be relatively easy to do with view lifecycle from arch components, but this is not available yet (only for fragment itself, but it's not what you need), so I see only way with custom fragment, where you can register listener on view destroy, that will just clear view property inside of delegate
feature of the library
Whole library is just one file and full implementation for fragment is about 10 lines, so It's doable
nullable vars
It's not a way how kotterknife works now
u
how would you even do it, if not nullable vars? you need to null the reference in onDetroyView no?
g
This is just delegate property (so for one just a method), so yeah, for user of this delegate property it looks like val, but under the hood, even current implementation, it's a class with var property (btw non-nullable), the only thing that you need is set default value/null to this delegate class property on fragment's view destroy