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) {
   }
 }
  public static void initImageLoader(Context context) {

    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
    config.tasksProcessingOrder(QueueProcessingType.LIFO);

    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());
  }
示例#3
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.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    config.writeDebugLogs(); // Remove for release app

    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());
  }
示例#4
0
  /**
   * Loads the imageLoader question required for downloading the images
   *
   * @param context the application context
   * @return the image loader
   */
  public static ImageLoader loadImageLoader(Context context) {
    DisplayImageOptions displayImageOptions =
        new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(true).build();

    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.defaultDisplayImageOptions(displayImageOptions);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
    config.memoryCacheSize(50 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    config.writeDebugLogs(); // Remove for release app
    ImageLoader.getInstance().init(config.build());

    return ImageLoader.getInstance();
  }