本文整理了Java中com.bumptech.glide.request.target.ViewTarget.setTagId()
方法的一些代码示例,展示了ViewTarget.setTagId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ViewTarget.setTagId()
方法的具体详情如下:
包路径:com.bumptech.glide.request.target.ViewTarget
类名称:ViewTarget
方法名:setTagId
[英]Sets the android resource id to use in conjunction with View#setTag(int,Object)to store temporary state allowing loads to be automatically cancelled and resources re-used in scrolling lists.
If no tag id is set, Glide will use View#setTag(Object).
Warning: prior to Android 4.0 tags were stored in a static map. Using this method prior to Android 4.0 may cause memory leaks and isn't recommended. If you do use this method on older versions, be sure to call com.bumptech.glide.RequestManager#clear(View) on any view you start a load into to ensure that the static state is removed.
[中]将android资源id设置为与View#setTag(int,Object)结合使用,以存储临时状态,允许自动取消加载,并在滚动列表中重复使用资源。
如果未设置标记id,Glide将使用View#setTag(对象)。
警告:在Android 4.0之前,标签存储在静态地图中。在Android 4.0之前使用这种方法可能会导致内存泄漏,不推荐使用。如果在旧版本上使用此方法,请务必调用com。邦普泰克。滑行RequestManager#清除(视图)启动加载到的任何视图,以确保静态被删除。
代码示例来源:origin: waynell/VideoListPlayer
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
ViewTarget.setTagId(R.id.glide_loader);
builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter
() {
@Override
public File getCacheDirectory() {
return context.getExternalCacheDir();
}
}, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
}
代码示例来源:origin: w0080626/GankIO
@Override
public void applyOptions(Context context, GlideBuilder builder) {
ViewTarget.setTagId(R.id.image_tag);
}
代码示例来源:origin: mylhyl/Android-Zxing
@Override
public void onCreate() {
super.onCreate();
//因为Glide加载图片的源码中也使用了setTag和getTag模式而
//https://github.com/bumptech/glide/issues/370
ViewTarget.setTagId(R.string.app_name);
}
}
代码示例来源:origin: licheedev/Custom-Glide-ModelLoader-Demo
@Override
public void applyOptions(Context context, GlideBuilder builder) {
ViewTarget.setTagId(R.id.glide_tag_id); // 设置别的get/set tag id,以免占用View默认的
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); // 设置图片质量为高质量
}
内容来源于网络,如有侵权,请联系作者删除!