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

UIL unable to load image when source is PHOTO_URI of contact #564

Closed
evgenyh opened this issue Mar 11, 2014 · 7 comments
Closed

UIL unable to load image when source is PHOTO_URI of contact #564

evgenyh opened this issue Mar 11, 2014 · 7 comments
Labels

Comments

@evgenyh
Copy link

evgenyh commented Mar 11, 2014

for example :
uri : content://com.android.contacts/display_photo/2
this code fails :
ImageLoader.getInstance().displayImage(phoneContact.getImageURI(), photo);
with the following error :
E/ImageLoader(13761): Image can't be decoded [content://com.android.contacts/display_photo/2_480x800]

at the same time , this code :
photo.setImageBitmap(android.provider.MediaStore.Images.Media.getBitmap(this.getContentResolver(),Uri.parse(phoneContact.getImageURI())));

works as excpected.

@nostra13
Copy link
Owner

You can try to extend BaseImageDownloader and override getStreamFromContent(...) method:

@Override
protected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException {
        ContentResolver res = context.getContentResolver();
        Uri uri = Uri.parse(imageUri);
        if (imageUri.startsWith("content://com.android.contacts/")) {
            return ContactsContract.Contacts.openContactPhotoInputStream(res, uri);
        } else {
            return res.openInputStream(uri);
        }
    }

@evgenyh
Copy link
Author

evgenyh commented Mar 11, 2014

looks like this works. thanks

whether it will be integrated within this library ?

2014-03-11 21:36 GMT+02:00 Sergey Tarasevich notifications@github.com:

You can try to extend BaseImageDownloader and override
getStreamFromContent(...) method:

@Overrideprotected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException {
ContentResolver res = context.getContentResolver();
Uri uri = Uri.parse(imageUri);
if (imageUri.startsWith("content://com.android.contacts/")) {
return ContactsContract.Contacts.openContactPhotoInputStream(res, uri);
} else {
return res.openInputStream(uri);
}
}

Reply to this email directly or view it on GitHubhttps://github.com//issues/564#issuecomment-37339936
.

@nostra13
Copy link
Owner

Maybe. Let me think about it.

@evgenyh
Copy link
Author

evgenyh commented Mar 12, 2014

Strange, but at the same time , such uri : content://com.android.contacts/contacts/9/photo_166x170

loaded without problems and without code changes you suggested.

ok, so far I've found the pattern :
these uris works :
content://com.android.contacts/contacts/315/photo_125x128
content://com.android.contacts/contacts/147/photo_480x800

these , doesn't :
content://com.android.contacts/display_photo/2_480x800
content://com.android.contacts/display_photo/4_480x800

and each time it fails I see in logcat right before the error message :
03-12 10:18:25.752: D/skia(3946): --- SkImageDecoder::Factory returned null

@jmrboosties
Copy link

I see that the master branch has been updated to correct this, are you going to release a new .jar file for it? Thanks!

@nostra13
Copy link
Owner

nostra13 commented Apr 1, 2014

I'm going to but I can't say the date of release.

@nostra13
Copy link
Owner

Done in 1.9.2.

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

No branches or pull requests

3 participants