https://kotlinlang.org logo
Title
u

ursus

06/02/2018, 7:45 PM
if usting KOTTERKNIFE in fragment,
private val registerTextView: TextView by bindView(R.id.registerTextView)
g

gildor

06/03/2018, 12:41 PM
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

ursus

06/03/2018, 4:08 PM
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

gildor

06/03/2018, 4:22 PM
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

ursus

06/03/2018, 11:10 PM
how would you even do it, if not nullable vars? you need to null the reference in onDetroyView no?
g

gildor

06/03/2018, 11:31 PM
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