Search code examples
androidandroid-intentandroid-activityandroid-imageviewandroid-glide

unable to load Glide with uri


I am working on an App, where, I am listening to image share requests.

<intent-filter>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*"/>
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE"/>
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*"/>
</intent-filter>

I am able to get the Uri(s) of the images shared.

private ArrayList<Uri> mGalleryImagesList;

if(recievedAction == Intent.ACTION_SEND){  
    mSelectedImages.add(Uri.parse(extras.get(Intent.EXTRA_STREAM).toString()));
}
else if(recievedAction == Intent.ACTION_SEND_MULTIPLE){
    ArrayList<Parcelable> fileList = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);

    for (Parcelable file: fileList) {
        mSelectedImages.add(Uri.parse(file.toString()));
    }
}

However, when I am trying to load ImageView, using Glide, it is not loading, I am seeing only the place holder.

...

@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
    Glide.with (mContext)
            .load(mGalleryImagesList.get(position))
            .centerCrop()
            .placeholder(R.drawable.image_loading)
            .crossFade()
            .into(holder.imgAlbum);
}

Example of Uri that I got when I shared a photo using "Photos" app to my App. content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Ffile%2F3924/ORIGINAL/NONE/1472614544

No exceptions, only issue is that, ImageView is not loaded.


Solution

  • Image may be too large try to resize it.

    Glide.with (mContext)
            .load(mGalleryImagesList.get(position))
            .centerCrop()
            .placeholder(R.drawable.image_loading)
            .resize(holder.imgAlbum.getLayoutParams().width, holder.imgAlbum.getLayoutParams().height)
            .crossFade()
            .into(holder.imgAlbum);