/** * 初始化方法(初始化各种缓存配置),推荐在Application中调用 * * @param context */ public static void init(Context context, CacheConfig config) { imageLoader = new ImageLoader(); imageLoader.context = context; /** 如果配置了CacheConfig,则使用配置的Config;否则,使用默认的Config */ imageLoader.config = null != config ? config : new CacheConfig(); imageLoader.memoryCache = new MemoryCache(config.getMemoryCachelimit()); /** 如果在config中配置了缓存目录,则使用之;否则,使用默认的缓存路径 */ imageLoader.fileCache = new FileCache( imageLoader.context, null != config.getFileCachePath() ? config.getFileCachePath() : Environment.getExternalStorageDirectory().toString() + "/Android/data/" + context.getPackageName() + "/cache"); }