Java Code Examples for com.nostra13.universalimageloader.core.DisplayImageOptions#Builder

The following examples show how to use com.nostra13.universalimageloader.core.DisplayImageOptions#Builder . 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: Utility.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
private static DisplayImageOptions getDisplayImageOptionsFactory(int resId) {
    if (mOptionsMap.containsKey(resId)) {
        return mOptionsMap.get(resId);
    }
    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
    builder.imageScaleType(ImageScaleType.EXACTLY).cacheOnDisk(true)
            .cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new FadeInBitmapDisplayer(300));

    if (resId != 0) {
        builder.showImageOnFail(resId).showImageForEmptyUri(resId)
                .showImageOnLoading(resId);
    }
    mOptions = builder.build();
    mOptionsMap.put(resId, mOptions);
    return mOptions;
}
 
Example 2
Source File: ImageLoaderOptions.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
public static DisplayImageOptions getOptionsCachedDisk(boolean isUser) {
        DisplayImageOptions.Builder builder;
        if (isUser) {
            builder = getBaseOptionsUser()
                    .cacheInMemory(false).cacheOnDisk(true)
                    .resetViewBeforeLoading(true)
                    .considerExifParams(true);
        } else {
            builder = getBaseOptions()
                    .cacheInMemory(false).cacheOnDisk(true)
                    .resetViewBeforeLoading(true)
                    .considerExifParams(true);
        }
        return builder.build();
//                .setDiskCache(new UnlimitedDiskCache(
//                        StorageUtils.getCacheDirectory(context));
    }
 
Example 3
Source File: MainActivity.java    From MutiPhotoChoser with Mozilla Public License 2.0 6 votes vote down vote up
private void initImageLoader() {
    if (!ImageLoader.getInstance().isInited()) {
        DisplayImageOptions.Builder displayBuilder = new DisplayImageOptions.Builder();
        displayBuilder.cacheInMemory(true);
        displayBuilder.cacheOnDisk(true);
        displayBuilder.showImageOnLoading(com.ns.mutiphotochoser.R.drawable.default_photo);
        displayBuilder.showImageForEmptyUri(com.ns.mutiphotochoser.R.drawable.default_photo);
        displayBuilder.considerExifParams(true);
        displayBuilder.bitmapConfig(Bitmap.Config.RGB_565);
        displayBuilder.imageScaleType(ImageScaleType.EXACTLY);
        displayBuilder.displayer(new FadeInBitmapDisplayer(300));

        ImageLoaderConfiguration.Builder loaderBuilder = new ImageLoaderConfiguration.Builder(getApplication());
        loaderBuilder.defaultDisplayImageOptions(displayBuilder.build());
        loaderBuilder.memoryCacheSize(getMemoryCacheSize());

        try {
            File cacheDir = new File(getExternalCacheDir() + File.separator + CacheConstant.IMAGE_CACHE_DIRECTORY);
            loaderBuilder.diskCache(new LruDiscCache(cacheDir, DefaultConfigurationFactory.createFileNameGenerator(), 500 * 1024 * 1024));
        } catch (IOException e) {
            e.printStackTrace();
        }
        ImageLoader.getInstance().init(loaderBuilder.build());
    }

}
 
Example 4
Source File: DisplayConfig.java    From TestChat with Apache License 2.0 6 votes vote down vote up
/**
         * 获取图片加载器的图片的配置
         *
         * @param isRound  是否是加载圆形图片
         * @param defaultRes  默认图片ID
         * @return  返回配置
         */
        public static DisplayImageOptions getDefaultConfig(boolean isRound,int defaultRes) {
                DisplayImageOptions.Builder builder=new DisplayImageOptions.Builder();
//                设置缓存到内存和SD卡中,设置图片的解码格式
                builder.cacheInMemory(true).cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565);
//                考虑JPEG图像EXIF参数(旋转和翻转)
                builder.imageScaleType(ImageScaleType.EXACTLY_STRETCHED);
//                设置圆形图片
                if (isRound) {
                        builder.considerExifParams(true).displayer(new RoundedBitmapDisplayer(12));
                }
//                设置下载前图片重置复位
                builder.resetViewBeforeLoading(true);
//                设置图片下载失败的时候加载默认的图片
                if (defaultRes != 0) {
                        builder.showImageForEmptyUri(defaultRes).showImageOnFail(defaultRes);
                }
                return builder.build();
        }
 
Example 5
Source File: ImageConfig.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions getDefaultImageOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .resetViewBeforeLoading(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .displayer(new FadeInBitmapDisplayer(700))
            .cacheOnDisk(true)
            .cacheInMemory(false);
    return options.build();
}
 
Example 6
Source File: ViewerImageLoader.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private DisplayImageOptions.Builder getOptionsWp() {
	return new DisplayImageOptions.Builder()
			.showImageForEmptyUri(BaseApplication.sDefaultImageDrawable)
			.showImageOnFail(BaseApplication.sDefaultImageDrawable)
			.showImageOnLoading(BaseApplication.sDefaultImageDrawable)
			.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
			.bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
			.displayer(new FadeInBitmapDisplayer(300));
}
 
Example 7
Source File: ImageConfig.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions getWallpaperOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .bitmapConfig(Bitmap.Config.ARGB_8888)
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .cacheOnDisk(true)
            .cacheInMemory(false);
    return options.build();
}
 
Example 8
Source File: ImageConfig.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions getDefaultImageOptions(boolean cacheOnDisk) {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .resetViewBeforeLoading(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .displayer(new FadeInBitmapDisplayer(700))
            .cacheOnDisk(cacheOnDisk)
            .cacheInMemory(false);
    return options.build();
}
 
Example 9
Source File: ImageConfig.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions.Builder getRawDefaultImageOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY);
    return options;
}
 
Example 10
Source File: ImageConfig.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions getWallpaperOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .bitmapConfig(Bitmap.Config.ARGB_8888)
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .cacheOnDisk(true)
            .cacheInMemory(false);
    return options.build();
}
 
Example 11
Source File: ViewerImageLoader.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private DisplayImageOptions.Builder getOptions() {
	return new DisplayImageOptions.Builder()
			.showImageForEmptyUri(R.drawable.zg_default_pic_beizi_64)
			.showImageOnFail(R.drawable.zg_default_pic_beizi_64)
			.showImageOnLoading(R.drawable.zg_default_pic_beizi_64)
			.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
			.bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
			.displayer(new FadeInBitmapDisplayer(300));
}
 
Example 12
Source File: ImageLoadUtil.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * 构造图片显示的配置选项
 *
 * @param placeHolderImgRes 默认的占位显示图片
 * @param emptyUrlImgRes    空链接显示的图片
 * @param failedImgRes      加载失败显示的图片
 * @param cacheInMemory     是否内存缓存,图片过大,建议不要内存缓存
 * @return
 */
private static DisplayImageOptions constructDisplayOption(String url, int placeHolderImgRes, int emptyUrlImgRes,
                                                          int failedImgRes, boolean cacheInMemory, BitmapDisplayer displayer) {
    DisplayImageOptions.Builder bulider = new DisplayImageOptions.Builder();
    bulider.cacheOnDisc(true); // 默认开启磁盘缓存 缓存在默认位置
    // /sdcard/Android/data/[package_name]/cache
    bulider.cacheInMemory(cacheInMemory);
    bulider.resetViewBeforeLoading(true);
    bulider.bitmapConfig(Bitmap.Config.RGB_565);
    // bulider.displayer(new FadeInBitmapDisplayer(200));//加载动画
    if (displayer != null) {
        bulider.displayer(displayer);
    }

    if (placeHolderImgRes > 0) {
        bulider.showStubImage(placeHolderImgRes);
    }

    if (emptyUrlImgRes > 0) {
        bulider.showImageForEmptyUri(emptyUrlImgRes);
    }

    if (failedImgRes > 0) {
        bulider.showImageOnFail(failedImgRes);
    }

    return bulider.build();
}
 
Example 13
Source File: DemoActivity.java    From Masaccio with Apache License 2.0 5 votes vote down vote up
private static DisplayImageOptions getProcessorDisplayImageOptions(
        final BitmapProcessor processor) {

    final DisplayImageOptions.Builder defaultOptionsBuilder = new DisplayImageOptions.Builder();

    return defaultOptionsBuilder.imageScaleType(ImageScaleType.NONE)
            .postProcessor(processor)
            .build();
}
 
Example 14
Source File: ImageLoaderUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取图片默认加载配置
 * @param loadingRes 设置加载中显示的图片
 * @return {@link DisplayImageOptions}
 */
public static DisplayImageOptions getDefaultImageOptions(@DrawableRes final int loadingRes) {
    DisplayImageOptions.Builder optionsBuilder = cloneImageOptions(DF_OPTIONS);
    optionsBuilder.showImageOnLoading(loadingRes) // 设置图片在下载期间显示的图片
            .showImageForEmptyUri(loadingRes) // 设置图片 Uri 为空或是错误的时候显示的图片
            .showImageOnFail(loadingRes); // 设置图片 ( 加载 / 解码 ) 过程中错误时候显示的图片
    return optionsBuilder.build();
}
 
Example 15
Source File: ImageConfig.java    From candybar with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions.Builder getRawImageOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .bitmapConfig(Bitmap.Config.ARGB_8888)
            .imageScaleType(ImageScaleType.EXACTLY);
    return options;
}
 
Example 16
Source File: ImageConfig.java    From candybar with Apache License 2.0 5 votes vote down vote up
public static DisplayImageOptions.Builder getRawDefaultImageOptions() {
    DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
    options.delayBeforeLoading(10)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY);
    return options;
}
 
Example 17
Source File: GalleryActivity.java    From MutiPhotoChoser with Mozilla Public License 2.0 5 votes vote down vote up
private void initImageLoader() {
    if (options == null) {
        DisplayImageOptions.Builder displayBuilder = new DisplayImageOptions.Builder();
        displayBuilder.cacheInMemory(true);
        displayBuilder.cacheOnDisk(true);
        displayBuilder.showImageOnLoading(R.drawable.default_photo);
        displayBuilder.showImageForEmptyUri(R.drawable.default_photo);
        displayBuilder.considerExifParams(true);
        displayBuilder.bitmapConfig(Bitmap.Config.RGB_565);
        displayBuilder.imageScaleType(ImageScaleType.EXACTLY);
        displayBuilder.displayer(new FadeInBitmapDisplayer(300));
        options = displayBuilder.build();
    }

    if (!ImageLoader.getInstance().isInited()) {
        ImageLoaderConfiguration.Builder loaderBuilder = new ImageLoaderConfiguration.Builder(getApplication());
        loaderBuilder.memoryCacheSize(getMemoryCacheSize());

        try {
            File cacheDir = new File(getExternalCacheDir() + File.separator + CacheConstant.IMAGE_CACHE_DIRECTORY);
            loaderBuilder.diskCache(new LruDiscCache(cacheDir, DefaultConfigurationFactory.createFileNameGenerator(), 500 * 1024 * 1024));
        } catch (IOException e) {
            e.printStackTrace();
        }
        ImageLoader.getInstance().init(loaderBuilder.build());
    }

}
 
Example 18
Source File: Utils.java    From KUAS-AP-Material with MIT License 4 votes vote down vote up
public static DisplayImageOptions.Builder getDefaultDisplayImageBuilder() {
	return new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true)
			.bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT)
			.displayer(new FadeInBitmapDisplayer(500));
}
 
Example 19
Source File: App.java    From 4pdaClient-plus with Apache License 2.0 4 votes vote down vote up
public static DisplayImageOptions.Builder getDefaultOptionsUIL() {
    return options;
}
 
Example 20
Source File: ImageLoaderUtils.java    From DevUtils with Apache License 2.0 2 votes vote down vote up
/**
 * 克隆图片加载配置
 * @param options 待克隆加载配置
 * @return {@link DisplayImageOptions}
 */
public static DisplayImageOptions.Builder cloneImageOptions(final DisplayImageOptions options) {
    return (options != null) ? new DisplayImageOptions.Builder().cloneFrom(options) : null;
}