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

[BUG] - ContextThemeWrapper cannot be cast to FragmentActivity while setImageUriAsync #136

Closed
WMariusz opened this issue Jun 2, 2021 · 2 comments · Fixed by #143
Closed

Comments

@WMariusz
Copy link

WMariusz commented Jun 2, 2021

  • Lib Version 3.1.1

Describe the bug
CropImageView.setImageUriAsync leads to
android.view.ContextThemeWrapper cannot be cast to androidx.fragment.app.FragmentActivity
when CropImageView is nested inside view that have overrided android:theme atribute

To Reproduce
Steps to reproduce the behavior:

  1. Set image uri on CropImageView with setImageUriAsync
  2. Apply ThemeOverlay by add it to view layout android:theme
  3. See error

Expected behavior
Try to unpack FragmentActivity from ContextThemeWrapper

Additional context
See https://github.com/WMariusz/Android-Image-Cropper/tree/bug/theme-overlay-context-wrapper
i have added two commits, first with bug and second with workaround that issue

@WMariusz WMariusz added the bug label Jun 2, 2021
@Canato
Copy link
Member

Canato commented Jun 3, 2021

Thanks for the detailed bug description and the commits.

Indeed we cannot expect that context will have/be a fragmentActivity and was a mistake that I didn't spot before.

Would you like to open a PR for the library with the fix issue? I'm just worry about the while inside getFragmentActivityFrom, maybe we could get block in a loop here forever?

But if you open the PR with the fix and updating the changelog we can merge and release =)

@WMariusz
Copy link
Author

WMariusz commented Jun 7, 2021

IMO this loop should not block app as long as view is created with activity context.

So you would have to create a view from some Service or other Activity, for example from NativeActivity to block it.

Right now i cant find better solution.

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