Esempio n. 1
0
  private void initImageLoader() {
    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisc(true)
            .displayer(new FadeInBitmapDisplayer(200))
            .showImageOnLoading(R.drawable.ic_avatar)
            .build();

    File cacheDir;
    if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
      cacheDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    } else {
      cacheDir = getCacheDir();
    }
    ImageLoaderConfiguration.Builder configBuilder =
        new ImageLoaderConfiguration.Builder(mContext)
            .threadPoolSize(2)
            .memoryCache(new WeakMemoryCache())
            .denyCacheImageMultipleSizesInMemory()
            .discCache(new UnlimitedDiscCache(cacheDir))
            .defaultDisplayImageOptions(options);
    if (BuildConfig.DEBUG) {
      configBuilder.writeDebugLogs();
    }
    ImageLoader.getInstance().init(configBuilder.build());
  }
Esempio 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.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());
  }
Esempio n. 3
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();
  }