wordpress-mobile / wordpress-mobile/WordPress-Android

onAttach/onDetach possible issues for Fragments

Open
#6,937 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Broken Window General
Dominant language
Kotlin
Stars
3.2k
Forks
1.4k
Avg merge
1d 11h
Merged PRs (30d)
69

Description

While working on #6906, I realized that we don't use the support version of the Fragment which leads to some issues with onAttach and onDetach. I haven't gone through the whole code base just yet, so I don't really know how big of a problem it is, but here is the problem:

onAttach(Activity activity) has been deprecated on API 23 and instead onAttach(Context context) has been introduced. Unfortunately, the context version does not get triggered for "< API 23" which means that code is never executed. The same thing applies for onDetach. I think the correct way to get around this issue and many possible other issues in the future is to use the support version of the Fragment, or any other UI component really. The regular version of Fragment classes never get updated and these issues come up, whereas the support versions are regularly updated so we don't need to deal with them.

As mentioned, I don't know how much this affects right now aside from #6906 just because I don't have the bandwidth to look into it today. However, if we agree this is the right course of action, I can have a look at this next Monday (December 11) when my Groundskeeper rotation starts.

/cc @maxme

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the onAttach and onDetach lifecycle entry points and trace Fragment usages related to #6906. Determine how the current platform Fragment behaves below and at API 23, then assess the scope of switching to support Fragments. Done means the affected callbacks work across the relevant API levels without leaving current Fragment usages inconsistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.