You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this weird problem where the Activity view's presenter is created but not attached the first time the activity is created. After that, if for example I press the home button and return to the activity everything works fine and the view is attached to the presenter with onStart().
Here is my code:
@ActivityView(layout = R.layout.activity_wallet_new, presenter = TestPresenter::class)
class TestActivity : AppCompatActivity(), TestView {
@Presenter
@JvmField
var presenter: TestPresenter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Horizon.zero(this).statusBarColor(R.color.statusBarColor).dawn()
}
override fun onStart() {
super.onStart()
Timber.d("onStart: presenter=%s", presenter)
}
}
presenter:
class TestPresenter: AbstractPresenter<TestView>() {
init {
Timber.d("init: test presenter created")
}
override fun onViewAttached(view: TestView?) {
super.onViewAttached(view)
Timber.d("onViewAttached: called")
}
override fun onViewDetached() {
super.onViewDetached()
Timber.d("onViewDetached: called.")
}
}
Note that the presenter constructor is called even on the first creation, it is just that it isn't attached (i.e. onViewAttached is not called and presenter is null in onStart() of the activity)
I tried rewriting everything in Java just to make sure it's not some freaky kapt problem. I also tried using an injected presenter and everything was the same.
Any ideas?
UPDATE:
here's the log output. I just realized when it's on Java, neither attach or detach is called the first time. On Kotlin, it even calls onViewDetached the first time but onViewAttached is only called from the second time on, here's the log output for Kotlin:
D/TestActivity: onStart: presenter=null
D/TestPresenter: init: test presenter created
[HIT HOME BUTTON AND RETURN TO ACTIVITY]
D/TestPresenter: onViewDetached: called.
D/TestPresenter: onViewAttached: called
D/TestActivity: onStart: presenter=com.example.foo.domain.TestPresenter@9c8b130
Now I'm really confused.
The text was updated successfully, but these errors were encountered:
Hi,
I ran into this weird problem where the Activity view's presenter is created but not attached the first time the activity is created. After that, if for example I press the home button and return to the activity everything works fine and the view is attached to the presenter with
onStart()
.Here is my code:
presenter:
view interface:
build.gradle:
easymvp version:
Note that the presenter constructor is called even on the first creation, it is just that it isn't attached (i.e. onViewAttached is not called and presenter is null in
onStart()
of the activity)I tried rewriting everything in Java just to make sure it's not some freaky
kapt
problem. I also tried using an injected presenter and everything was the same.Any ideas?
UPDATE:
here's the log output. I just realized when it's on Java, neither attach or detach is called the first time. On Kotlin, it even calls onViewDetached the first time but onViewAttached is only called from the second time on, here's the log output for Kotlin:
[HIT HOME BUTTON AND RETURN TO ACTIVITY]
Now I'm really confused.
The text was updated successfully, but these errors were encountered: