Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MyApplication.java
- public class McotApplication extends Application{
- ....
- @Override
- public void onCreate() {
- super.onCreate();
- ......
- File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
- //Display options for all display images.
- DisplayImageOptions options = new DisplayImageOptions.Builder()
- .showStubImage(R.drawable.mcot_default)
- .showImageForEmptyUri(R.drawable.mcot_default)
- .bitmapConfig(Bitmap.Config.RGB_565)
- // .cacheInMemory()
- .cacheOnDisc()
- .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build();
- // 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 config = new ImageLoaderConfiguration.Builder(getApplicationContext())
- .threadPoolSize(5)
- .threadPriority(Thread.NORM_PRIORITY)
- .defaultDisplayImageOptions(options)
- .memoryCache(new WeakMemoryCache())
- // .offOutOfMemoryHandling()
- // .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
- // .memoryCacheSize(memClass/4) // 5 Mb
- .denyCacheImageMultipleSizesInMemory()
- .discCache(new TotalSizeLimitedDiscCache(cacheDir, new Md5FileNameGenerator(), 15000000))//cache 15 MB
- //.enableLogging() // Not necessary in common
- .build();
- // Initialize ImageLoader with configuration.
- ImageLoader.getInstance().init(config);
- .....
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement