Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support detached Fragments by removing references to the Activity #613

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jimmithy
Copy link

@jimmithy jimmithy commented Apr 4, 2024

馃幆 Goal

Previously if we create a fragment that is not yet attached to the activity and reference the balloon, this will throw an IllegalStateException. This is because the lazy loader requires an Activity even thought the implementation only requires Context.

This change removes all references to activities, so the balloon can be successfully attached to the anchor without needing the activity context.

馃洜 Implementation details

  1. Update Lazy helpers to use requireContext instead of requireActivity
  2. Remove unused getActivity method
  3. Remove unneccesary Context.isFinishing method because isAttachedToWindow should resolve issue android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?聽#92

Code reviews

All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.

Context != Activity

This should resolve issues where the fragment is not attached to an activity. We already check that the context is not null earlier in the method
An alternative approach to skydoves#92 to avoid any reference to the activity

isAttachedToWindow will confirm that the anchor view has a valid window token.
@jimmithy jimmithy requested a review from skydoves as a code owner April 4, 2024 16:02
@skydoves
Copy link
Owner

skydoves commented Apr 16, 2024

Hey @jimmithy, checking out the isFinishing is needed for working correctly with Activity. I'm wondering if you can resolve this issue by calling the show method inside the If statements, which has isAttachedToWindow as a condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants