Advertisement
Guest User

UIL

a guest
Nov 23rd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. //MyApplication.java
  2. public class McotApplication extends Application{
  3. ....
  4.  
  5. @Override
  6.     public void onCreate() {
  7.         super.onCreate();
  8.         ......
  9.         File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
  10.  
  11.         //Display options for all display images.
  12.         DisplayImageOptions options = new DisplayImageOptions.Builder()
  13.         .showStubImage(R.drawable.mcot_default)
  14.         .showImageForEmptyUri(R.drawable.mcot_default)
  15.         .bitmapConfig(Bitmap.Config.RGB_565)
  16. //        .cacheInMemory()
  17.         .cacheOnDisc()
  18.         .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build();
  19.  
  20.         // This configuration tuning is custom. You can tune every option, you may tune some of them,
  21.         // or you can create default configuration by
  22.         //  ImageLoaderConfiguration.createDefault(this);
  23.         // method.
  24.         ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
  25.         .threadPoolSize(5)
  26.         .threadPriority(Thread.NORM_PRIORITY)
  27.         .defaultDisplayImageOptions(options)
  28.         .memoryCache(new WeakMemoryCache())
  29. //        .offOutOfMemoryHandling()
  30. //        .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
  31. //        .memoryCacheSize(memClass/4) // 5 Mb
  32.         .denyCacheImageMultipleSizesInMemory()
  33.         .discCache(new TotalSizeLimitedDiscCache(cacheDir, new Md5FileNameGenerator(), 15000000))//cache 15 MB
  34.         //.enableLogging() // Not necessary in common
  35.         .build();
  36.  
  37.         // Initialize ImageLoader with configuration.
  38.         ImageLoader.getInstance().init(config);
  39.         .....
  40.      }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement