com.nostra13.universalimageloader.core.download.BaseImageDownloader Java Examples

The following examples show how to use com.nostra13.universalimageloader.core.download.BaseImageDownloader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainApplication.java    From android-imageviewer with Apache License 2.0 6 votes vote down vote up
public static void initImageLoader(Context context) {
    File cacheDir = StorageUtils.getCacheDirectory(context);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .denyCacheImageMultipleSizesInMemory()
            .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
            .threadPriority(Thread.NORM_PRIORITY - 2) // default
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13) // default
            .discCache(new UnlimitedDiscCache(cacheDir)) // default
            .discCacheSize(50 * 1024 * 1024)
            .discCacheFileCount(100)
            .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(context)) // default
            .imageDecoder(new BaseImageDecoder(true)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .writeDebugLogs()
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example #2
Source File: ImageLoaderUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化 ImageLoader 加载配置
 * @param context {@link Context}
 */
public static void init(final Context context) {
    DisplayImageOptions options = DF_OPTIONS;
    // 针对图片缓存的全局加载配置 ( 主要有线程类、缓存大小、磁盘大小、图片下载与解析、日志方面的配置 )
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .defaultDisplayImageOptions(options) // 加载 DisplayImageOptions 参数
            .threadPriority(Thread.NORM_PRIORITY - 2) // 线程池内加载的数量
            .denyCacheImageMultipleSizesInMemory() // 加载同一 URL 图片时 imageView 从小变大时从内存缓存中加载
            //.memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024)) // 通过自己的内存缓存实现
            .memoryCacheSize(2 * 1024 * 1024) // 内存缓存最大值
            .memoryCacheSizePercentage(13)
            //.diskCacheSize(50 * 1024 * 1024) // SDCard 缓存最大值 50mb
            //.discCacheFileNameGenerator(new Md5FileNameGenerator()) // 将保存的时候的 URI 名称用 MD5 加密
            //.diskCacheFileCount(100) // 缓存的文件数量
            //.memoryCache(new WeakMemoryCache()).diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
            .imageDownloader(new BaseImageDownloader(context)) // default
            .tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
 
Example #3
Source File: MultiImageActivity.java    From commonadapter with MIT License 6 votes vote down vote up
/**
 * 初始化UniversalImageLoader
 */
private void configUniversalImageLoader() {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory().cacheOnDisc()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new FadeInBitmapDisplayer(500))
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).
            diskCacheFileCount(500)
            .diskCacheSize(50 * 1024 * 1024).
                    imageDownloader(new BaseImageDownloader(this, 10 * 1000, 20 * 1000))
            .memoryCacheSize((int) Runtime.getRuntime().maxMemory() / 8)
            .defaultDisplayImageOptions(defaultOptions).build();
    ImageLoader.getInstance().init(config);
}
 
Example #4
Source File: MyApplication.java    From WliveTV with Apache License 2.0 6 votes vote down vote up
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 - 4);
//        config.memoryCache(new WeakMemoryCache());
        config.memoryCacheExtraOptions(480, 800);
        config.memoryCacheSize(2 * 1024 * 1024);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.diskCacheExtraOptions(480, 800, null);
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
//        config.writeDebugLogs(); // Remove for release app
        config.imageDownloader(new BaseImageDownloader(context, 5 * 1000, 10 * 1000));
        config.threadPoolSize(1);
        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());
    }
 
Example #5
Source File: UniversalImageLoader.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
     * Get default ImageLoaderConfiguration.Builder,and you can easily change the builder.
     * @param context
     * @return
     */
    public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) {
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context)
//                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
//                .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 1) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
//                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
//                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
//                .discCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(1000)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                        //   .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .defaultDisplayImageOptions(getDefaultImageOptions());
        return builder;
    }
 
Example #6
Source File: VideoRow.java    From talk-android with MIT License 6 votes vote down vote up
Bitmap tryLoadBitmap(ImageViewAware imageAware) {
    Bitmap bitmap = null;
    try {
        java.io.File imageFile = diskCache.get(getMessage().get_id());
        if (imageFile != null && imageFile.exists() && imageFile.length() > 0) {
            ViewScaleType viewScaleType = imageAware.getScaleType();
            ImageSize imageSize = ImageSizeUtils.defineTargetSizeForView(imageAware, new ImageSize(MainApp.CONTEXT.getResources().getDisplayMetrics().widthPixels, MainApp.CONTEXT.getResources().getDisplayMetrics().heightPixels));
            ImageDecodingInfo decodingInfo = new ImageDecodingInfo(getMessage().get_id(),
                    ImageDownloader.Scheme.FILE.wrap(imageFile.getAbsolutePath()), getMessage().get_id(), imageSize, viewScaleType,
                    new BaseImageDownloader(MainApp.CONTEXT), options);
            bitmap = decoder.decode(decodingInfo);
            MainApp.memoryCache.put(getMessage().get_id(), bitmap);
        }
    } catch (Exception ignored) {
        ignored.printStackTrace();
    }
    return bitmap;
}
 
Example #7
Source File: MainApplication.java    From snowdream-books-android with Apache License 2.0 6 votes vote down vote up
private void initImageLoader(){
        Context context = getApplicationContext();
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiscCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
//                .writeDebugLogs()
                .build();

        ImageLoader.getInstance().init(config);
    }
 
Example #8
Source File: UniversalImageLoader.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) {
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context)
//                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
//                .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 1) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
//                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
//                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .discCache(new UnlimitedDiscCache(cacheDir)) // default
//                .discCacheSize(50 * 1024 * 1024)
                .discCacheFileCount(1000)
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                        //   .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .defaultDisplayImageOptions(getDefaultImageOptions());
        return builder;
    }
 
Example #9
Source File: ImageBaseUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context) {

        DisplayImageOptions options = getDefaultDisplayImageOptions();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(getDefaultImageCacheDir()))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example #10
Source File: ImageLoaderForUIL.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
public InputStream getStream(String imageUri, Object extra) throws IOException {
    switch (Scheme.ofUri(imageUri)) {
        case HTTP:
        case HTTPS:
            return DownloaderFactory.create(context, imageUri).getInputStream();
        case CONTENT:
            if (Build.VERSION.SDK_INT >= 19) {
                return DownloaderFactory.create(context, imageUri).getInputStream();
            }
    }
    return new BaseImageDownloader(context).getStream(imageUri, extra);
}
 
Example #11
Source File: ImageLibUitls.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context, File cacheDir, Drawable drawableEmpty, Drawable drawableFail) {

        DisplayImageOptions options = getDisplayImageOptions(drawableEmpty, drawableFail);


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(cacheDir))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example #12
Source File: ImageUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initNoCacheImageLoader(Context context) {



        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .resetViewBeforeLoading(false).delayBeforeLoading(100)
                .considerExifParams(false)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .displayer(new SimpleBitmapDisplayer()).handler(new Handler())
                .cacheInMemory(false).cacheOnDisk(false)
//                .showImageForEmptyUri(R.drawable.default_pic)
//                .showImageOnFail(R.drawable.default_pic)
                .build();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example #13
Source File: ImageUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context) {

        DisplayImageOptions options = getDefaultDisplayImageOptions();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(getDefaultCacheDir()))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example #14
Source File: ImageLoaderConfig.java    From fitness_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 异步图片加载ImageLoader的初始化操作,在Application中调用此方法
 * 
 * @param context
 *            上下文对象
 * @param cacheDisc
 *            图片缓存到SDCard的目录,只需要传入SDCard根目录下的子目录即可,默认会建立在SDcard的根目录下
 */
public static void initImageLoader(Context context, String cacheDisc) {
	
	// 配置ImageLoader
	// 获取本地缓存的目录,该目录在SDCard的根目录下
	File cacheDir = StorageUtils.getOwnCacheDirectory(context, cacheDisc);
	// 实例化Builder
	ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(
			context);
	// 设置线程数量
	builder.threadPoolSize(3);
	// 设定线程等级比普通低一点
	builder.threadPriority(Thread.NORM_PRIORITY);
	// 设定内存缓存为弱缓存
	builder.memoryCache(new WeakMemoryCache());
	// 设定内存图片缓存大小限制,不设置默认为屏幕的宽高
	builder.memoryCacheExtraOptions(480, 800);
	// 设定只保存同一尺寸的图片在内存
	builder.denyCacheImageMultipleSizesInMemory();
	// 设定缓存的SDcard目录,UnlimitDiscCache速度最快
	builder.discCache(new UnlimitedDiscCache(cacheDir));
	// 设定缓存到SDCard目录的文件命名
	builder.discCacheFileNameGenerator(new HashCodeFileNameGenerator());
	// 设定网络连接超时 timeout: 10s 读取网络连接超时read timeout: 60s
	builder.imageDownloader(new BaseImageDownloader(context, 10000, 60000));
	// 设置ImageLoader的配置参数
	builder.defaultDisplayImageOptions(initDisplayOptions(true));

	// 初始化ImageLoader
	ImageLoader.getInstance().init(builder.build());
}
 
Example #15
Source File: MYApplication.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public void initImage() {

    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.ic_stub)
            // 设置图片下载期间显示的图�?
            .showImageForEmptyUri(R.drawable.ic_empty)
            // 设置图片Uri为空或是错误的时候显示的图片
            .showImageOnFail(R.drawable.ic_error)
            // 设置图片加载或解码过程中发生错误显示的图�?
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .cacheInMemory(true) // 设置下载的图片是否缓存在内存�?
            .cacheOnDisc(true) // 设置下载的图片是否缓存在SD卡中
            // .displayer(new RoundedBitmapDisplayer(20)) // 设置成圆角图
            .build(); // 创建配置过得DisplayImageOption对象

    File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext())
            .memoryCacheExtraOptions(480, 800)
            // max width, max height,即保存的每个缓存文件的最大长宽
            .threadPoolSize(3)
            // 线程池内加载的数量
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
            // You can pass your own memory cache
            // implementation/你可以通过自己的内存缓存实现
            .memoryCacheSize(2 * 1024 * 1024)
            .discCacheSize(50 * 1024 * 1024)
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            // 将保存的时候的URI名称用MD5 加密
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .discCacheFileCount(100) // 缓存的文件数量
            .discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
            .imageDownloader(
                    new BaseImageDownloader(getApplicationContext(),
                            5 * 1000, 30 * 1000)) // connectTimeout (5 s),
                                                    // readTimeout (30
                                                    // s)超时时间
            .writeDebugLogs() // Remove for release app
            .build();// 开始构建
    ImageLoader.getInstance().init(config);

}
 
Example #16
Source File: DefaultConfigurationFactory.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static ImageDownloader createImageDownloader(Context context)
{
    return new BaseImageDownloader(context);
}
 
Example #17
Source File: DefaultConfigurationFactory.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
/** Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader} */
public static ImageDownloader createImageDownloader(Context context) {
	return new BaseImageDownloader(context);
}
 
Example #18
Source File: ImageLoaderSetting.java    From Pas with Apache License 2.0 4 votes vote down vote up
public static void initImageLoader(Context context) {

        // 设置缓存 路径
        File cacheDir = StorageUtils.getOwnCacheDirectory(context,
                "eh2h/imageloader/Cache");

        //默认
        defaultOptions = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher)
                .showImageForEmptyUri(R.mipmap.ic_launcher)
                .showImageOnFail(R.mipmap.ic_launcher)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .considerExifParams(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
                        //.displayer(new FadeInBitmapDisplayer(300, true, true, true))
                        //.displayer(new RoundedBitmapDisplayer(90))
                .delayBeforeLoading(100)//载入图片前稍做延时可以提高整体滑动的流畅度
                .bitmapConfig(Bitmap.Config.RGB_565).build();



        animateFirstListener = new AnimateFirstDisplayListener();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
               // .writeDebugLogs()
                .build();


        ImageLoader.getInstance().init(config);
    }
 
Example #19
Source File: ImageLoaderSetting.java    From Pas with Apache License 2.0 4 votes vote down vote up
public static void initImageLoader(Context context) {

        // 设置缓存 路径
        File cacheDir = StorageUtils.getOwnCacheDirectory(context,
                "eh2h/imageloader/Cache");

        //默认
        defaultOptions = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.defaultbg)
                .showImageForEmptyUri(R.mipmap.defaultbg)
                .showImageOnFail(R.mipmap.defaultbg)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .considerExifParams(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
                        //.displayer(new FadeInBitmapDisplayer(300, true, true, true))
                        //.displayer(new RoundedBitmapDisplayer(90))
                .delayBeforeLoading(100)//载入图片前稍做延时可以提高整体滑动的流畅度
                .bitmapConfig(Bitmap.Config.RGB_565).build();



        animateFirstListener = new AnimateFirstDisplayListener();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
               // .writeDebugLogs()
                .build();


        ImageLoader.getInstance().init(config);
    }
 
Example #20
Source File: DefaultConfigurationFactory.java    From WliveTV with Apache License 2.0 4 votes vote down vote up
/** Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader} */
public static ImageDownloader createImageDownloader(Context context) {
	return new BaseImageDownloader(context);
}
 
Example #21
Source File: DefaultConfigurationFactory.java    From candybar with Apache License 2.0 4 votes vote down vote up
/**
 * Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader}
 */
public static ImageDownloader createImageDownloader(Context context) {
    return new BaseImageDownloader(context);
}
 
Example #22
Source File: DefaultConfigurationFactory.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
/** Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader} */
public static ImageDownloader createImageDownloader(Context context) {
	return new BaseImageDownloader(context);
}
 
Example #23
Source File: DefaultConfigurationFactory.java    From mobile-manager-tool with MIT License 4 votes vote down vote up
/** Creates default implementation of {@link com.nostra13.universalimageloader.core.download.ImageDownloader} - {@link com.nostra13.universalimageloader.core.download.BaseImageDownloader} */
public static ImageDownloader createImageDownloader(Context context) {
	return new BaseImageDownloader(context);
}
 
Example #24
Source File: LetvCacheConfiguration.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void initCacheLibrary(Context context, LetvThumbnailUtils thumbnailUtils) {
    ImageLoader.getInstance().init(new Builder(context).memoryCache(getMemoryCache(context)).diskCache(getDiscCache()).threadPoolSize(3).threadPriority(3).denyCacheImageMultipleSizesInMemory().imageDownloader(new BaseImageDownloader(context)).tasksProcessingOrder(QueueProcessingType.LIFO).setThumbnailUtils(thumbnailUtils).writeDebugLogs().build());
}
 
Example #25
Source File: DefaultConfigurationFactory.java    From letv with Apache License 2.0 4 votes vote down vote up
public static ImageDownloader createImageDownloader(Context context) {
    return new BaseImageDownloader(context);
}
 
Example #26
Source File: ImageLoaderManager.java    From FimiX8-RE with MIT License 4 votes vote down vote up
private ImageLoaderManager(Context context, int emptyUri) {
    ImageLoader.getInstance().init(new Builder(context).threadPoolSize(4).threadPriority(3).denyCacheImageMultipleSizesInMemory().memoryCache(new WeakMemoryCache()).diskCacheSize(DISK_CACHE_SIZE).diskCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).defaultDisplayImageOptions(getDefaultOptions(emptyUri)).imageDownloader(new BaseImageDownloader(context, 5000, 30000)).writeDebugLogs().build());
    mLoader = ImageLoader.getInstance();
}
 
Example #27
Source File: DefaultConfigurationFactory.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 2 votes vote down vote up
/**
 * Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader}
 * 创建默认的图片下载器
 */
public static ImageDownloader createImageDownloader(Context context) {
	return new BaseImageDownloader(context);
}