android / android/architecture-samples
[todo-mvp-dagger] dropView method in Presenter
- Dominant language
- Kotlin
- Stars
- 45.8k
- Forks
- 11.9k
- PR merge metrics
- No merged PRs in 30d
Description
In presenters we have the dropView() method which sets the corresponding view to null.
Is it possible that in two Fragments (of the same class) the same Presenter will be provided? And then, when one of the fragments will be destroyed, the dropView() call will cause the presenter to loose the connection with the newly created fragment.
To prevent that, we could pass the view in dropView(view) and then check if it is that very view that Presenter actually holds like that:
```
dropView(MainContract.View view) {
if (mView == view) mView = null;
}
```
So, my question actually can be rephrased whether it is possible that two fragments of the same class could get the same instance of Presenter by dagger and if not - why that situation could not happen?
Contributor guide
Research direction
Trace the Presenter dropView() calls and Dagger provisioning used by the relevant Fragments. Determine whether two same-class Fragments can receive one Presenter instance, then define the expected lifecycle behavior and verify it with the existing presenter or Fragment tests, if present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100