Subsampling Scale Image View自身只支持本地图片的加载,但项目中还需要显示网络图片,不想分情况选用不同的控件,所以通过Glide将图片下载到本地缓存再显示
//使用Glide下载图片,保存到本地
Glide.with(context)
.download(uri)
.into(new SimpleTarget<File>() {
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
Log.d("load failed", "nothing");
}
@Override
public void onResourceReady(File resource, Transition<? super File> transition) {
mPlaceHolder.setVisibility(GONE);
imageView.setImage(ImageSource.uri(resource.getAbsolutePath()));
imageView.setMaxScale(10f);
}