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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We can't have multiple constructPermissionsRequest within the same fragment #755

Open
SamYStudiO opened this issue Nov 20, 2021 · 3 comments

Comments

@SamYStudiO
Copy link

SamYStudiO commented Nov 20, 2021

Hello,

I have 2 constructPermissionsRequest (one for location and one for external storage) from the same fragment (i don't make them using the same construct because i want to call them in the right context and so they need to be call at different time).

Problem is the second one will never gets its callbacks called once the first one has been accepted.
this is because when you call PermissionsRequesterImpl.launch ALL observers are removed.

Here is a user case >

  • you construct 2 permissions
  • you click a button which call the first permission and accept it, everything is fine so far
  • you click again that button PermissionsRequesterImpl detect it is accepted and remove observers
  • you click a second button to call 2 permissions and this time you never get notified beacause there is no more observers

Solution would be to have a unique observer for each PermissionsRequesterImpl

Environment

  • core 4.9.1
  • ktx 1.1.3
@hotchemi
Copy link
Member

Thank you so much! would you mind sending a PR?

@ColorfulHorse
Copy link

maybe dont need removeObservers?

@kimukou
Copy link

kimukou commented Nov 13, 2023

PermissionsRequesterImpl

ViewModelProvider(activity).get(PermissionRequestViewModel::class.java).observe

owner is not good

Fragment.constructPermissionsRequest

owner is Fragment better use not actiity
and
i hope PermissionsRequester add function clear(inner call removeObservers)

Currently, if you implement call with multiple Fragments,
it may refer to a Fragment that has already been destroyed, resulting in a crash.

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

No branches or pull requests

4 participants