android / android/architecture-samples

Linking Presenter with View (Fragment)

Open
#576 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
45.8k
Forks
11.9k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/googlesamples/android-architecture/blob/30f7c5a16bb0854e003530e81403e922e745d311/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/addedittask/AddEditTaskActivity.java#L86

Please do correct me if I am wrong, but isn't this approach as bad as creating a Fragment with argument constructor?

Although, the above implementation would work fine, since we are linking the presenter to the fragment in `onCreate()` method of the Activity, which will surely get called whenever the system kills and later recreates my activity instance.

But consider this scenario:
Suppose I am adding a fragment to my screen on some button click. If Android then decides to kill my fragment, and later recreates it using a no-arg constructor call, then there won't be any presenter attached to the fragment if I have linked it with this approach, is this correct?

Contributor guide

Open the contributing guide

Research direction

Start with AddEditTaskActivity.java at line 86 and inspect how the presenter is linked to the fragment during activity recreation. Compare that flow with the fragment lifecycle scenario described in the issue. Done means confirming whether the presenter is restored or identifying the lifecycle-safe change required; no test or target file is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.