慕娘9325324
试试 implementation 'com.github.bumptech.glide:glide:4.8.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'演示@GlideModulepublic class FlickrGlideModule extends AppGlideModule { @Override public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { super.applyOptions(context, builder); builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888)); } @Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { registry.append(Photo.class, InputStream.class, new FlickrModelLoader.Factory()); } // Disable manifest parsing to avoid adding similar modules twice. @Override public boolean isManifestParsingEnabled() { return false; }}读 AppGlideModule供参考你的loadImage方法将是public static void loadImage(Context ctx,RequestOptions glideRequests, String url, ImageView imageView) { loadImage(ctx,glideRequests, url, imageView, DiskCacheStrategy.ALL); } public static void loadImage(Context ctx,RequestOptions glideRequests, String url, ImageView imageView, DiskCacheStrategy diskCacheStrategy) { Glide.with(ctx) .applyDefaultRequestOptions(requestOptions.placeholder(R.drawable.ic_stub).error(R.drawable.ic_stub)) .asBitmap() .load(url).into(imageView); }然后ImageUtil.loadImage(context,options,obj.getPhotoUrl(),avatarImageView);
BIG阳
尝试这个进口Glide在增加的gradle这个compile 'com.github.bumptech.glide:glide:3.8.0'然后使用此代码Glide.with(context) .load(url) .placeholder(R.drawable.ic_male) .error(R.drawable.imagenotfound) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { // log exception Log.e("TAG", handle error case", e); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { Log.e("TAG", handle success case here", e); return false; } }) .into(avatarImageView);