GlideCatchSimple
Introduction: Glide 缓存工具例子,缓存大小获取,磁盘缓存清除(2 种方法),内存缓存清除
Tags:
Glide-Glide 缓存 Simple
- 缓存路径的指定
- 缓存大小的获取
- 磁盘缓存清除(两种方法)
内存缓存清除
可 clone 之后查看使用 Simple
Glide cache Simple.
- The cache path specified
- The cache size
- The disk cache (two ways)
Memory cache to clearMay
use Simple clone after check
GlideCatchUtil
获取 Glide 磁盘缓存大小
public String getCacheSize() {
try {
return getFormatSize(getFolderSize(new File(Application.getInstance().getCacheDir() + "/" + GlideCatchConfig.GLIDE_CARCH_DIR)));
} catch (Exception e) {
e.printStackTrace();
return "获取失败";
}
}
清除 Glide 磁盘缓存
public boolean cleanCatchDisk() {
return deleteFolderFile(Application.getInstance().getCacheDir() + "/" + GlideCatchConfig.GLIDE_CARCH_DIR, true);
}
public boolean clearCacheDiskSelf() {
try {
if (Looper.myLooper() == Looper.getMainLooper()) {
new Thread(new Runnable() {
@Override
public void run() {
Glide.get(Application.getInstance()).clearDiskCache();
}
}).start();
} else {
Glide.get(Application.getInstance()).clearDiskCache();
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
AndroidMainfest.xml and GlideConfiguration.class
<meta-data
android:name="com.yaphetzhao.glidecatchsimple.glide.GlideConfiguration"
android:value="GlideModule" />
Application.class
public class Application extends android.app.Application {
public static Application instance;
public static Application getInstance() {
return instance;
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
}
}
<application
android:name=".Application"
more...
About Me
YaphetZhao Email:yaphetzhao@gmail.com Email_CN:yaphetzhao@foxmail.com GitHub:http://github.com/YaphetZhao/ QQ:11613371 CSDN_Blog:http://blog.csdn.net/yaphetzhao