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()); }
private void initImageLoader() { try { String CACHE_DIR = Environment.getExternalStorageDirectory().getAbsolutePath() + "/.temp_tmp"; new File(CACHE_DIR).mkdirs(); File cacheDir = StorageUtils.getOwnCacheDirectory(getBaseContext(), CACHE_DIR); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheOnDisc(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .build(); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(getBaseContext()) .defaultDisplayImageOptions(defaultOptions) .discCache(new UnlimitedDiscCache(cacheDir)) .memoryCache(new WeakMemoryCache()); ImageLoaderConfiguration config = builder.build(); imageLoader = ImageLoader.getInstance(); imageLoader.init(config); } catch (Exception e) { } }
private void configImageLoader() { File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext()); if (cacheDir == null) { cacheDir = Environment.getDownloadCacheDirectory(); } // TODO config image resolution cache for low end devices DisplayImageOptions options = getDefaultDisplayOptionsBuilder().build(); int maxWidth = 800; int maxHeight = 480; int threadPoolSize = 1; ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(getApplicationContext()) .threadPoolSize(threadPoolSize) .memoryCacheExtraOptions(maxWidth, maxHeight) .memoryCache(new LRULimitedMemoryCache(3 * 1024 * 1024)) .diskCacheExtraOptions(maxWidth, maxHeight, null) .diskCache(new LimitedAgeDiskCache(cacheDir, 3600 * 24 * 7)) .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) .imageDownloader(new BaseImageDownloader(getApplicationContext())) .defaultDisplayImageOptions(options); ImageLoaderConfiguration config = builder.build(); ImageLoader mImageLoader = ImageLoader.getInstance(); mImageLoader.init(config); }
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) { } }
private void initImageLoader() { ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(this) .threadPoolSize(3) .threadPriority(Thread.NORM_PRIORITY - 2) .memoryCacheSize(1500000) // 1.5 Mb .denyCacheImageMultipleSizesInMemory() .memoryCache(new WeakMemoryCache()) .discCacheFileNameGenerator(new Md5FileNameGenerator()); ImageLoaderConfiguration config = builder.build(); imageLoader = ImageLoader.getInstance(); imageLoader.init(config); }
/** * 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(); }
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()); }
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()); }
@Provides @Singleton public ImageLoader imageLoader(SharedPreferencesWrapper preferences, MediaDownloader downloader) { final ImageLoader loader = ImageLoader.getInstance(); final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(application); cb.threadPriority(Thread.NORM_PRIORITY - 2); cb.denyCacheImageMultipleSizesInMemory(); cb.tasksProcessingOrder(QueueProcessingType.LIFO); // cb.memoryCache(new ImageMemoryCache(40)); cb.diskCache(createDiskCache("images", preferences)); cb.imageDownloader(new TwidereImageDownloader(application, downloader)); L.writeDebugLogs(BuildConfig.DEBUG); loader.init(cb.build()); return loader; }
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(); }
private ImageLoaderConfiguration(ImageLoaderConfiguration.Builder paramBuilder) { this.a = ImageLoaderConfiguration.Builder.a(paramBuilder).getResources(); this.s = ImageLoaderConfiguration.Builder.b(paramBuilder); this.t = ImageLoaderConfiguration.Builder.c(paramBuilder); this.b = ImageLoaderConfiguration.Builder.d(paramBuilder); this.c = ImageLoaderConfiguration.Builder.e(paramBuilder); this.d = ImageLoaderConfiguration.Builder.f(paramBuilder); this.e = ImageLoaderConfiguration.Builder.g(paramBuilder); this.f = ImageLoaderConfiguration.Builder.h(paramBuilder); this.i = ImageLoaderConfiguration.Builder.i(paramBuilder); this.j = ImageLoaderConfiguration.Builder.j(paramBuilder); this.k = ImageLoaderConfiguration.Builder.k(paramBuilder); this.m = ImageLoaderConfiguration.Builder.l(paramBuilder); this.l = ImageLoaderConfiguration.Builder.m(paramBuilder); this.p = ImageLoaderConfiguration.Builder.n(paramBuilder); this.n = ImageLoaderConfiguration.Builder.o(paramBuilder); this.o = ImageLoaderConfiguration.Builder.p(paramBuilder); this.g = ImageLoaderConfiguration.Builder.q(paramBuilder); this.h = ImageLoaderConfiguration.Builder.r(paramBuilder); this.q = new g(this.n); this.r = new h(this.n); L.writeDebugLogs(ImageLoaderConfiguration.Builder.s(paramBuilder)); }
private static ImageLoaderConfiguration buildConfiguration(Context context) { ImageLoaderConfiguration.Builder configuration = new ImageLoaderConfiguration.Builder(context); return configuration.build(); }