GlideCatchSimple

简介:Glide 缓存工具例子,缓存大小获取,磁盘缓存清除(2 种方法),内存缓存清除
更多:作者   提 Bug   
标签:
Glide-

Glide 缓存 Simple

  1. 缓存路径的指定
  2. 缓存大小的获取
  3. 磁盘缓存清除(两种方法)
  4. 内存缓存清除

  5. 可 clone 之后查看使用 Simple

Glide cache Simple.

  1. The cache path specified
  2. The cache size
  3. The disk cache (two ways)
  4. Memory cache to clearMay

  5. 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

自己记录、分享给好友:
为什么今年工作这么难找?
为什么今年工作这么难找?