Ejemplo n.º 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) {
   }
 }
Ejemplo n.º 2
0
  public static void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them,
    // or you can create default configuration by
    //  ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.MAX_PRIORITY);
    config.threadPoolSize(10);
    config.denyCacheImageMultipleSizesInMemory();
    config.memoryCacheSizePercentage(20); // % of available app memory..
    config.tasksProcessingOrder(QueueProcessingType.FIFO);
    //        config.writeDebugLogs(); // Remove for release app

    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());

    sDisplayImageLoaderOptions =
        new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
  }