Open pcutting opened 3 years ago
You can get the Drawable by adding listener.
Glide.with(this).load(R.mipmap.movie).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
Bitmap bitmap = ((BitmapDrawable)resource).getBitmap();
return false;
}
}).into(imageView)
Kotlin, Android studio.
I'm at my wits end on trying to get a Drawable resource from glide for a exoPlayer defaultArtwork property.
From another post I see a method .asBitmap(). I'm guessing this has been removed? I'm trying to load an image from a string url.
(The following doesn't recognize .asBitmap() as a method for glide.
When I try to just go with .load, I get a type mismatch.
I'm getting:
Not surprisingly when I try with .fallbackDrawable, nothing happens (no image is loaded).
I'm sure that's not it's intended usage anyways.
Just to test, when I do the following it does load a default image:
Reference: Similar to: https://github.com/bumptech/glide/issues/843
Glide V: implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' Gradle V: classpath "com.android.tools.build:gradle:4.1.3"
Video: (sorry if it's not very helpful) https://www.loom.com/share/7b2b40497e2342a7a4ac93b77543df3d
Activity code:
Going to attach the gradle file here because it asnweres most of the questions on the setup.