i have creating Hindi video song application, but video thumb can't display in video list. (Single image are loaded but multiple image array can't load.)
using multiple image loader library but doesn't load image:
Glide:
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
Glide .with(viewHolder.icon_1.getContext())
.load(((AppModelicon) this.b.get(i)).getThumnail())
.into(viewHolder.icon_1) ;
Glide.with(MainActivity.this)
.load("https://img.youtube.com/vi/EEX_XM6SxmY/mqdefault.jpg")
.placeholder(R.drawable.ic_menu_camera)
.error(R.drawable.ic_menu_gallery)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
// log exception
Log.e("TAG", "Error loading image", e);
return false; // important to return false so the error placeholder can be placed
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.into(viewHolder.icon_1);
Picasso:
implementation 'com.squareup.picasso:picasso:2.+'
Picasso.get()
.load("https://img.youtube.com/vi/EEX_XM6SxmY/mqdefault.jpg")
.resize(50, 50)
.centerCrop()
.into(viewHolder.icon_1);
using request manager with glide :
RequestManager requestManager = Glide.with(a)
.applyDefaultRequestOptions(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
.applyDefaultRequestOptions(RequestOptions.placeholderOf(R.drawable.ic_menu_camera));
requestManager
.applyDefaultRequestOptions(RequestOptions.skipMemoryCacheOf(true));
requestManager.load(pathToFile)
.into(viewHolder.icon_1);
background task method use :
String pathToFile = this.b.get(i).getThumnail();
DownloadImageWithURLTask downloadTask = new DownloadImageWithURLTask(viewHolder.icon_1);
downloadTask.execute(pathToFile);
public class DownloadImageWithURLTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageWithURLTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String pathToFile = urls[0];
Bitmap bitmap = null;
try {
InputStream in = new java.net.URL(pathToFile).openStream();
bitmap = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
Please help me how to solve this issue.

Dont pass MainActivity.this as context its always wrong..
try this
replace .load("url") and "imageView" with your own.