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

136 fix get fragmentactivity from contextwrapper #143

Merged
merged 4 commits into from
Jun 10, 2021

Conversation

Canato
Copy link
Member

@Canato Canato commented Jun 9, 2021

close #136

Bug

Cause:

android.view.ContextThemeWrapper cannot be cast to androidx.fragment.app.FragmentActivity

Reproduce

GIVEN: Version 3.1.1 of the library, view have attibute android:theme
WHEN: using CropImageView.setImageUriAsync() method
THEN: method try to cast ContextThemeWrapper to FragmentActivity

How the bug was solved:

Change the WorkerJobs to use the Context and for the thread we create a CoroutineScope inside the class

@Canato Canato requested a review from a team as a code owner June 9, 2021 09:40
@Canato Canato merged commit dd34ec9 into main Jun 10, 2021
@Canato Canato deleted the 136-fix-get-fragmentactivity-from-contextwrapper branch June 10, 2021 16:42
@WMariusz
Copy link

Are you sure that coroutineContext of this BitmapLoadingWorkerJob and BitmapCroppingWorkerJob wont leak at some point.

Jobs get canceled only by their start method.

What will happen if someone call CropImageView.setImageUriAsync() on different CropImageView?

Sorry i did not write earlier, i didnt had time yesterday.

@Canato
Copy link
Member Author

Canato commented Jun 11, 2021

@WMariusz good point, I expected they will not leak because if you call again will generate a new scope and a new job or will override it. I will check the flow on setImageUriAsync but if you spot anything let me know and we can fix =D

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.

[BUG] - ContextThemeWrapper cannot be cast to FragmentActivity while setImageUriAsync
2 participants