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

Fix android.resource Uris that point to a vector drawable fail to load #51

Conversation

pkpdeveloper
Copy link

@pkpdeveloper pkpdeveloper commented Aug 20, 2019

Hi @colinrtwhite,

Please review and merge fix for android.resource Uri related issue. also added test cases for that.
I have tried many solutions only this one works as expected.

Please let me know for further improvements or any discussion.

Cheers 🍻 for creating this awesome library 👏 ❤️

@pkpdeveloper pkpdeveloper force-pushed the android_resource_uri_vector_load_bug_fix branch 4 times, most recently from c57eb92 to 797fb3d Compare August 20, 2019 10:28
if (data.scheme == ContentResolver.SCHEME_ANDROID_RESOURCE) {
val resourceId = extractResourceId(data)
resourceId?.let {
val drawable = context.getDrawableCompat(resourceId)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this code part assumes that resourceId belongs to same applications. However Uri can point to resourceId which belongs to different application:

"android.resource:https://{pkgName}/{resourceId}"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @audkar for pointing this issue. I got the solution from Glide source code
I will do the changes ASAP 😊

@pkpdeveloper pkpdeveloper force-pushed the android_resource_uri_vector_load_bug_fix branch 3 times, most recently from 4941a03 to 6040e5d Compare August 21, 2019 10:14
@audkar
Copy link

audkar commented Aug 21, 2019

Implementation logic seems correct and aligned with platform one (private method used for ImageView.setImageURI(uri)). Handles boths possible formats for resource uri. Good job

@pkpdeveloper pkpdeveloper force-pushed the android_resource_uri_vector_load_bug_fix branch 3 times, most recently from 3abac39 to 5bb3cd4 Compare August 22, 2019 14:08
@pkpdeveloper pkpdeveloper force-pushed the android_resource_uri_vector_load_bug_fix branch from 5bb3cd4 to a38df6b Compare August 22, 2019 15:19
@colinrtwhite
Copy link
Member

Thanks for the contribution. We're working on a bigger refactor of the mappers + fetchers here, which might conflict with this PR. I'll circle back and review this PR after the one I linked is merged.

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.

None yet

3 participants