Support detached Fragments by removing references to the Activity #613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 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 anActivity
even thought the implementation only requiresContext
.This change removes all references to activities, so the balloon can be successfully attached to the anchor without needing the activity context.
🛠 Implementation details
requireContext
instead ofrequireActivity
getActivity
methodContext.isFinishing
method becauseisAttachedToWindow
should resolve issue android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? #92Code 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.