Initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.mogo.utils.glide;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.GlideBuilder;
|
||||
import com.bumptech.glide.annotation.GlideModule;
|
||||
import com.bumptech.glide.load.Key;
|
||||
import com.bumptech.glide.load.engine.Resource;
|
||||
import com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory;
|
||||
import com.bumptech.glide.load.engine.cache.LruResourceCache;
|
||||
import com.bumptech.glide.load.engine.cache.MemoryCache;
|
||||
import com.bumptech.glide.module.AppGlideModule;
|
||||
|
||||
/**
|
||||
* Created by congtaowang on 2018/12/17.
|
||||
*/
|
||||
@GlideModule
|
||||
public class BaseGlideModule extends AppGlideModule {
|
||||
|
||||
public static final int MEMORY_CACHE_SIZE = 5 * 1024 * 1024;
|
||||
public static final int DISK_CACHE_SIZE = 50 * 1024 * 1024;
|
||||
public static final String DISK_CACHE_NAME = "glide";
|
||||
|
||||
@Override
|
||||
public void applyOptions( Context context, GlideBuilder builder ) {
|
||||
super.applyOptions( context, builder );
|
||||
/**
|
||||
* 更改缓存最总文件夹名称
|
||||
*
|
||||
* 是在sdcard/Android/data/包名/cache/DISK_CACHE_NAME目录当中
|
||||
*/
|
||||
builder.setMemoryCache( new LruResourceCache( MEMORY_CACHE_SIZE ) );
|
||||
builder.setDiskCache( new ExternalPreferredCacheDiskCacheFactory( context, DISK_CACHE_NAME, DISK_CACHE_SIZE ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user