图像加载有问题。仅某些图像未加载。我已经尝试过使用滑行和图像加载器。
滑行代码:
Glide.with(context)
.load(model.getImage4x3().trim()+"?w=430&h=275")
.into(holder.mBinding.ivPromotion);
滑行依赖项:
implementation 'com.github.bumptech.glide:glide:4.9.0'
我也尝试过:3.9.0,4.0.0,3.6.1,3.8.0
错误:
load failed for http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08 with size [320x240]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 4 causes:
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, DATA_DISK_CACHE, http://mcms-uat.mercatus.com.sg/en/-/media/E3BE24B58E1144228C62D2364F4FF543.ashx?rev=50ebbcc572e6488c826a23276ab9bf08
Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
图片:
请检查!
答案 0 :(得分:1)
1) Add below dependencies into app/build.gradle
annotationProcessor 'com.github.bumptech.glide:compiler:your_glide_version'
2)将android:largeHeap =“ true”放入清单文件的标签
3)并按以下方式使用
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
Glide.with(context) // this
.load(imagePath)
.placeholder(R.drawable.loading_spinner)
.into(imageView);
答案 1 :(得分:1)
滑行加载大图像时出现问题
使用Picasso库
实现'com.squareup.picasso:picasso:2.5.2'
或者您也可以使用可在其网站上使用的facebook库(这也会很好地加载gif图像)。
答案 2 :(得分:1)
只需使用此方法即可完成。如果无法解决问题,请使用Picasso Library,因为Glide Itself已经解决了这个问题。
Glide.with(context)
.asBitmap()
.load("Your Network Image Path")
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
iv.setImageBitmap(resource);
iv.buildDrawingCache();
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) { }
});
答案 3 :(得分:0)
谢谢大家的回答和建议。我已经解决了问题。我的URL参数存在问题,它是?w = 430&h = 275而不是&w = 430&h = 275。由于此图片未裁剪,因此在加载大图片时出现问题。所以我通过更改参数来解决它