Balloon icon indicating copy to clipboard operation
Balloon copied to clipboard

Support detached Fragments by removing references to the Activity

Open jimmithy opened this issue 10 months ago • 1 comments

🎯 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 #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.

jimmithy avatar Apr 04 '24 16:04 jimmithy

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.

skydoves avatar Apr 16 '24 05:04 skydoves

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.

Hey, I wasn't entirely sure what you were suggesting, but I've restored the isFinishing check in a way that makes the context implementation not necessary.

jimmithy avatar Jun 23 '24 17:06 jimmithy