Пример #1
0
 public void init(Context context) {
   try {
     if (!ImageLoader.getInstance().isInited()) { // 未初始化则初始化
       // 默认缓存路径
       String cache_path = "";
       cache_path += PreferencesUtils.getString(context, "sys_path_sd_card");
       cache_path += PreferencesUtils.getString(context, "sys_path_app_folder");
       cache_path += PreferencesUtils.getString(context, "sys_path_cache");
       File cache = new File(cache_path);
       if (!cache.exists()) cache.mkdirs();
       // --
       ImageLoaderConfiguration.Builder config_builder =
           new ImageLoaderConfiguration.Builder(context);
       config_builder.threadPoolSize(3);
       config_builder.diskCacheSize(700 * 1024 * 1024);
       config_builder.diskCache(new UnlimitedDiscCache(cache));
       config_builder.diskCacheFileNameGenerator(new Md5FileNameGenerator());
       config_builder.tasksProcessingOrder(QueueProcessingType.FIFO);
       config_builder.imageDownloader(new BaseImageDownloader(context, 5 * 1000, 30 * 1000));
       // config_builder.writeDebugLogs();
       // --
       // ImageLoader.getInstance().destroy();
       ImageLoader.getInstance().init(config_builder.build());
     }
   } catch (Exception e) {
   }
 }
Пример #2
0
 @Provides
 @Singleton
 public ImageLoader imageLoader(SharedPreferencesWrapper preferences, MediaDownloader downloader) {
   final ImageLoader loader = ImageLoader.getInstance();
   final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(application);
   cb.threadPriority(Thread.NORM_PRIORITY - 2);
   cb.denyCacheImageMultipleSizesInMemory();
   cb.tasksProcessingOrder(QueueProcessingType.LIFO);
   // cb.memoryCache(new ImageMemoryCache(40));
   cb.diskCache(createDiskCache("images", preferences));
   cb.imageDownloader(new TwidereImageDownloader(application, downloader));
   L.writeDebugLogs(BuildConfig.DEBUG);
   loader.init(cb.build());
   return loader;
 }