Glide doesn't seem to process Uri content photos automatically.
So, I solved the problem using the RxJava approach.
Here is a method that emits a bitmap (pay attention to the scheduler, as it is important to keep up with scroll performance)
private Observable<Bitmap> _getConvertInputStreamToBitmapObservable(ContentResolver cr, Uri contactUri) { return Observable.create(new Observable.OnSubscribe<Bitmap>() { @Override public void call(Subscriber<? super Bitmap> subscriber) { InputStream inputStream = ContactsContract.Contacts.openContactPhotoInputStream(cr, contactUri); if (inputStream != null) { Bitmap bitmap = BitmapFactory.decodeStream(inputStream); subscriber.onNext(bitmap); } subscriber.onCompleted(); } }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); }
And here is the client code that uses this method (pay attention to unsubscribing, since this is important when disposing).
if (holder.bitmapSubscription != null) { holder.bitmapSubscription.unsubscribe(); } holder.bitmapSubscription = _getConvertInputStreamToBitmapObservable(context.getContentResolver(), contactUri) .subscribe(holder.userImg::setImageBitmap);
source share