Closed mikaelzero closed 6 years ago
The view is bound after it is ready to use, which is after onStart
. This prevents you from accessing the view before the layout is inflated or fragments are commited.
The presenter #onCreate
is called before your Activity#onCreate()
.
Thank you for your answer
use sendToView before onStart use getView other state is right?
It depends. I use getView
when the view calls a method of my presenter and I can synchronously update the view. If anything is async I'd use sendToView
.
Alternatively you can write some kind of render method. Update you model in the presenter and call render
which is the only place the view gets updated. Like this:
private val count = 0
override fun onAttachView(view: MyView) {
render()
}
override fun onButtonPressed() {
count++
render()
}
private fun render() {
if (view == null) return // view not attached
view.updateCount(count)
// ...
}
i think you use sendToView becasue of not call setContetView()
if i call bindView after setContentView()
or inflate()
getView() can work
i think...
have to use sendToView() to update the view? why not bindView in onCreate