Java Code Examples for com.nostra13.universalimageloader.core.assist.ImageScaleType

The following examples show how to use com.nostra13.universalimageloader.core.assist.ImageScaleType. These examples are extracted from open source projects. 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 Project: MiBandDecompiled   Source File: DisplayImageOptions.java    License: Apache License 2.0 6 votes vote down vote up
public Builder()
{
    a = 0;
    b = 0;
    c = 0;
    d = null;
    e = null;
    f = null;
    g = false;
    h = false;
    i = false;
    j = ImageScaleType.IN_SAMPLE_POWER_OF_2;
    k = new android.graphics.BitmapFactory.Options();
    l = 0;
    m = false;
    n = null;
    o = null;
    p = null;
    q = DefaultConfigurationFactory.createBitmapDisplayer();
    r = null;
    s = false;
    k.inPurgeable = true;
    k.inInputShareable = true;
}
 
Example 2
Source Project: DroidDLNA   Source File: ImageDisplay.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.image_display);

	mContext = this;
	options = new DisplayImageOptions.Builder()
			.showImageForEmptyUri(R.drawable.ic_empty)
			.showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading()
			.cacheOnDisc().imageScaleType(ImageScaleType.EXACTLY)
			.bitmapConfig(Bitmap.Config.RGB_565)
			.displayer(new FadeInBitmapDisplayer(300)).build();

	initView();
	initData();
	showImage(mPlayUri);

	addShake();
}
 
Example 3
Source Project: MutiPhotoChoser   Source File: MainActivity.java    License: 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 Project: ChatView   Source File: App.java    License: MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // UNIVERSAL IMAGE LOADER SETUP
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .resetViewBeforeLoading(true)
            .cacheOnDisk(true)
            .cacheInMemory(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .displayer(new FadeInBitmapDisplayer(300))
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
            .defaultDisplayImageOptions(defaultOptions)
            .memoryCache(new WeakMemoryCache())
            .diskCacheSize(100 * 1024 * 1024)
            .build();

    ImageLoader.getInstance().init(config);
    // END - UNIVERSAL IMAGE LOADER SETUP
}
 
Example 5
Source Project: TestChat   Source File: DisplayConfig.java    License: 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 6
Source Project: letv   Source File: LoadAndDisplayImageTask.java    License: Apache License 2.0 6 votes vote down vote up
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    File targetFile = this.configuration.diskCache.get(this.uri);
    if (targetFile == null || !targetFile.exists()) {
        return false;
    }
    Bitmap bmp = this.decoder.decode(new ImageDecodingInfo(this.memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), this.uri, new ImageSize(maxWidth, maxHeight), ViewScaleType.FIT_INSIDE, getDownloader(), new Builder().cloneFrom(this.options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build()));
    if (!(bmp == null || this.configuration.processorForDiskCache == null)) {
        L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, this.memoryCacheKey);
        bmp = this.configuration.processorForDiskCache.process(bmp);
        if (bmp == null) {
            L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, this.memoryCacheKey);
        }
    }
    if (bmp == null) {
        return false;
    }
    boolean saved = this.configuration.diskCache.save(this.uri, bmp);
    bmp.recycle();
    return saved;
}
 
Example 7
Source Project: letv   Source File: BaseImageDecoder.java    License: Apache License 2.0 6 votes vote down vote up
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    int scale;
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        boolean powerOf2;
        ImageSize targetSize = decodingInfo.getTargetSize();
        if (scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2) {
            powerOf2 = true;
        } else {
            powerOf2 = false;
        }
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && this.loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), Integer.valueOf(scale), decodingInfo.getImageKey());
    }
    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
 
Example 8
Source Project: letv   Source File: TitlePopupMenu.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint({"InflateParams"})
public TitlePopupMenu(Context context, int width, int height) {
    this.LIST_PADDING = 10;
    this.mRect = new Rect();
    this.mLocation = new int[2];
    this.popupGravity = 0;
    this.menus = new ArrayList();
    this.menusAdapter = new MenusAdapter();
    this.mContext = context;
    this.options = new Builder().showImageOnLoading(R.drawable.lemallsdk_icon_default).showImageForEmptyUri(R.drawable.lemallsdk_icon_default).showImageOnFail(R.drawable.lemallsdk_icon_default).cacheInMemory(true).cacheOnDisc(true).bitmapConfig(Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT).displayer(new SimpleBitmapDisplayer()).build();
    setFocusable(true);
    setTouchable(true);
    setOutsideTouchable(true);
    this.mScreenWidth = ScreenUtil.getScreenWidth(this.mContext);
    this.mScreenHeight = ScreenUtil.getScreenHeight(this.mContext);
    setWidth(width);
    setHeight(height);
    setAnimationStyle(R.style.AnimationPreview);
    update();
    setBackgroundDrawable(new BitmapDrawable());
    setContentView(LayoutInflater.from(this.mContext).inflate(R.layout.lemallsdk_title_popup_menu, null));
    initUI();
}
 
Example 9
Source Project: moviedb-android   Source File: SimilarAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public SimilarAdapter(Context context, int resource, ArrayList<SimilarModel> objects) {
    super(context, resource, objects);
    vi = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resource = resource;
    similarList = objects;
    imageLoader = ImageLoader.getInstance();
    options = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. Caching images in memory else
            // flicker while toolbar hiding
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheInMemory(true)
            .showImageOnLoading(R.drawable.placeholder_default)
            .showImageForEmptyUri(R.drawable.placeholder_default)
            .showImageOnFail(R.drawable.placeholder_default)
            .cacheOnDisk(true)
            .build();
}
 
Example 10
Source Project: moviedb-android   Source File: MovieAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public MovieAdapter(Context context, int resource, ArrayList<MovieModel> objects) {
    super(context, resource, objects);
    vi = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resource = resource;
    moviesList = objects;
    imageLoader = ImageLoader.getInstance();
    options = new DisplayImageOptions.Builder()
            // Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888. Caching images in memory else
            // flicker while toolbar hiding
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheInMemory(true)
            .showImageOnLoading(R.drawable.placeholder_default)
            .showImageForEmptyUri(R.drawable.placeholder_default)
            .showImageOnFail(R.drawable.placeholder_default)
            .cacheOnDisk(true)
            .build();
}
 
Example 11
Source Project: XRichText   Source File: UILKit.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化
 *
 * @param context
 */
private UILKit(Context context) {
    File cacheDir = getDiskCacheDir(context, "img");

    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCacheSize(10 * 1024 * 1024)
            .diskCache(new UnlimitedDiskCache(cacheDir))
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCacheSize(50 * 1024 * 1024) // 50 MiB
            .tasksProcessingOrder(QueueProcessingType.LIFO);

    ImageLoader.getInstance().init(config.build());



    picOptions = new DisplayImageOptions.Builder()
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisk(false).cacheInMemory(false)
            .resetViewBeforeLoading(true)
            .displayer(new FadeInBitmapDisplayer(500)).build();
}
 
Example 12
Source Project: LLApp   Source File: ImageLoaders.java    License: Apache License 2.0 6 votes vote down vote up
public static void setdailyfineimg(String url, ImageView imageView,
									   ImageLoadingListener listener) {
		if (dailyfines == null) {
			dailyfines = new DisplayImageOptions.Builder()
					.showImageOnLoading(0)
					.showImageForEmptyUri(0)
					.showImageOnFail(0)
					.cacheInMemory(true)
//					.cacheOnDisk(true)
					.considerExifParams(true)
					.bitmapConfig(Bitmap.Config.RGB_565)
					.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
					.build();
		}

		ImageLoader.getInstance().displayImage(url, imageView, dailyfines,
				listener);
	}
 
Example 13
Source Project: MultipleImagePicker   Source File: CustomGalleryActivity.java    License: Apache License 2.0 6 votes vote down vote up
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) {

	}
}
 
Example 14
Source Project: v2ex-daily-android   Source File: Application.java    License: Apache License 2.0 6 votes vote down vote up
private void initiImageLoader() {
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisc(true)
            .displayer(new FadeInBitmapDisplayer(200))
            .showImageOnLoading(R.drawable.ic_launcher)
            .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());
}
 
Example 15
Source Project: BigApp_WordPress_Android   Source File: BaseImageDecoder.java    License: Apache License 2.0 6 votes vote down vote up
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    int scale;
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        ImageSize targetSize = decodingInfo.getTargetSize();
        boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
    }

    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
 
Example 16
Source Project: BigApp_WordPress_Android   Source File: DialogShare.java    License: Apache License 2.0 6 votes vote down vote up
private void setWeiboImage(Platform.ShareParams sp) {
    try {
        ImageLoader.getInstance().loadImageSync(imageUrl, new DisplayImageOptions.Builder()
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
                .cacheInMemory(false).cacheOnDisk(true).resetViewBeforeLoading(true)
                .considerExifParams(true).build());
        String path = ImageLoader.getInstance().getDiskCache().get(imageUrl).getPath();
        if (TextUtils.isEmpty(path)) {
            return;
        }
        sp.setImagePath(path);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
Example 17
Source Project: ImageLoadingView   Source File: MyApp.java    License: Apache License 2.0 6 votes vote down vote up
private void initImageLoader(Context context) {
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheSize(50 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    ImageLoader.getInstance().init(config.build());

    defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.IN_SAMPLE_INT)//设置图片以如何的编码方式显示
            .showImageOnLoading(R.mipmap.loading)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .showImageOnFail(R.mipmap.loading)
            .showImageForEmptyUri(R.mipmap.loading)
            .build();

    ImageLoader.getInstance().clearDiskCache();
    ImageLoader.getInstance().clearMemoryCache();
}
 
Example 18
Source Project: WliveTV   Source File: BaseImageDecoder.java    License: Apache License 2.0 6 votes vote down vote up
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	int scale;
	if (scaleType == ImageScaleType.NONE) {
		scale = 1;
	} else if (scaleType == ImageScaleType.NONE_SAFE) {
		scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
	} else {
		ImageSize targetSize = decodingInfo.getTargetSize();
		boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
		scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
	}
	if (scale > 1 && loggingEnabled) {
		L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
	}

	Options decodingOptions = decodingInfo.getDecodingOptions();
	decodingOptions.inSampleSize = scale;
	return decodingOptions;
}
 
Example 19
Source Project: WliveTV   Source File: BaseDataAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public BaseDataAdapter(Context context, List<? extends BmobObject> mDatas) {
    this.context = context;
    this.mDatas = mDatas;
    options = new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.mipmap.icon_live_item_default)
            .showImageForEmptyUri(R.mipmap.icon_live_item_default)
            .showImageOnFail(R.mipmap.icon_live_item_default)
            .cacheInMemory(false)
            .cacheOnDisk(true)
            .considerExifParams(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new SimpleBitmapDisplayer())
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .build();
    if (this.context == null) {
        System.out.println("this.context is null");
    } else {
        mlayoutInflate = LayoutInflater.from(this.context);
    }
}
 
Example 20
private void init() {
    mLayoutInflater = LayoutInflater.from(getContext());

    // Get singleton instance
    mImageLoader = ImageLoader.getInstance();
    mDisplayImageOptions = new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.drawable.image_loading)
            .showImageOnFail(R.drawable.image_loading)
            .cacheOnDisk(true)
            .cacheInMemory(true)
            .resetViewBeforeLoading(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.ARGB_8888)
            .considerExifParams(true)
            .build();

}
 
Example 21
Source Project: candybar   Source File: BaseImageDecoder.java    License: Apache License 2.0 5 votes vote down vote up
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
                                                   int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    // Scale to exact size if need
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
        float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
                .getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1f) != 0) {
            m.setScale(scale, scale);

            if (loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
            }
        }
    }
    // Flip bitmap if need
    if (flipHorizontal) {
        m.postScale(-1, 1);

        if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
    }
    // Rotate bitmap if need
    if (rotation != 0) {
        m.postRotate(rotation);

        if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
    }

    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
            .getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
 
Example 22
Source Project: candybar   Source File: ImageConfig.java    License: 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 23
Source Project: candybar   Source File: ImageConfig.java    License: 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 24
Source Project: Conquer   Source File: ImageLoadOptions.java    License: Apache License 2.0 5 votes vote down vote up
/** 新闻列表中用到的图片加载配置 */
public static DisplayImageOptions getOptions() {
	DisplayImageOptions options = new DisplayImageOptions.Builder()
	// // 设置图片在下载期间显示的图片
	// .showImageOnLoading(R.drawable.small_image_holder_listpage)
	// // 设置图片Uri为空或是错误的时候显示的图片
	// .showImageForEmptyUri(R.drawable.small_image_holder_listpage)
	// // 设置图片加载/解码过程中错误时候显示的图片
	// .showImageOnFail(R.drawable.small_image_holder_listpage)
			.cacheInMemory(true)
			// 设置下载的图片是否缓存在内存中
			.cacheOnDisc(true)
			// 设置下载的图片是否缓存在SD卡中
			.considerExifParams(true).imageScaleType(ImageScaleType.EXACTLY)// 设置图片以如何的编码方式显示
			.bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型
			// .decodingOptions(android.graphics.BitmapFactory.Options
			// decodingOptions)//设置图片的解码配置
			.considerExifParams(true)
			// 设置图片下载前的延迟
			// .delayBeforeLoading(int delayInMillis)//int
			// delayInMillis为你设置的延迟时间
			// 设置图片加入缓存前,对bitmap进行设置
			// 。preProcessor(BitmapProcessor preProcessor)
			.resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位
			// .displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少
			.displayer(new FadeInBitmapDisplayer(100))// 淡入
			.build();

	return options;
}
 
Example 25
Source Project: YTPlayer   Source File: Utils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void initImageLoader(Context context) {
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .showImageOnLoading(R.drawable.ic_pulse)
            .showImageForEmptyUri(R.drawable.ic_pulse)
            .showImageOnFail(R.drawable.ic_pulse)
            .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
            .bitmapConfig(Bitmap.Config.ARGB_8888)
            .displayer(new FadeInBitmapDisplayer(500))
            .handler(new Handler()).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .memoryCache(new WeakMemoryCache()).defaultDisplayImageOptions(options).memoryCacheSizePercentage(13).build();
    ImageLoader.getInstance().init(config);
}
 
Example 26
Source Project: MutiPhotoChoser   Source File: GalleryActivity.java    License: 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 27
Source Project: fitness_Android   Source File: ImageLoaderConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 返回默认的参数配置
 * 
 * @param isShowDefault
 *            true:显示默认的加载图片 false:不显示默认的加载图片
 * @return
 */
public static DisplayImageOptions initDisplayOptions(boolean isShowDefault) {
	DisplayImageOptions.Builder displayImageOptionsBuilder = new DisplayImageOptions.Builder();
	
	// 设置图片缩放方式
	// EXACTLY: 图像将完全按比例缩小的目标大小
	// EXACTLY_STRETCHED: 图片会缩放到目标大小
	// IN_SAMPLE_INT: 图像将被二次采样的整数倍
	// IN_SAMPLE_POWER_OF_2: 图片将降低2倍,直到下一减少步骤,使图像更小的目标大小
	// NONE: 图片不会调整
	
	displayImageOptionsBuilder.imageScaleType(ImageScaleType.EXACTLY);
	if (isShowDefault) {
		// 默认显示的图片
		displayImageOptionsBuilder.showStubImage(R.drawable.loading_animation);
		// 地址为空的默认显示图片
		displayImageOptionsBuilder
				.showImageForEmptyUri(R.drawable.default_image);
		// 加载失败的显示图片
		displayImageOptionsBuilder.showImageOnFail(R.drawable.default_image);
	}
	// 开启内存缓存
	displayImageOptionsBuilder.cacheInMemory(true);
	// 开启SDCard缓存
	displayImageOptionsBuilder.cacheOnDisc(true);
	// 设置图片的编码格式为RGB_565,此格式比ARGB_8888快
	displayImageOptionsBuilder.bitmapConfig(Bitmap.Config.RGB_565);

	return displayImageOptionsBuilder.build();
}
 
Example 28
Source Project: android-imageviewer   Source File: ImageViewerActivity.java    License: Apache License 2.0 5 votes vote down vote up
public void loadData() {
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .resetViewBeforeLoading(true)
            .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .cacheInMemory(false)
            .considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300))
            .build();
    viewPager.setAdapter(new ImageViewerPagerAdapter(this, imageUrls, options));
    viewPager.setCurrentItem(imagePosition);
}
 
Example 29
Source Project: UltimateAndroid   Source File: UniversalImageLoader.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Return default DisplayImageOptions.Builder
 * @return
 */
public static DisplayImageOptions.Builder getDefaultImageOptionsBuilder() {
    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder()
            .resetViewBeforeLoading(false)  // default
                    //  .delayBeforeLoading(1000)
          //  .showImageOnLoading(R.drawable.titanic_wave_black)
            .considerExifParams(false) // default
            .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
            .bitmapConfig(Bitmap.Config.ARGB_8888) // default
            .displayer(new SimpleBitmapDisplayer()) // default
            .handler(new Handler()) // default
            .cacheInMemory(true)
            .cacheOnDisk(true);
    return builder;
}
 
Example 30
ImageAdapter(Context context) {
	inflater = LayoutInflater.from(context);

	options = new DisplayImageOptions.Builder()
			.showImageForEmptyUri(R.drawable.ic_empty)
			.showImageOnFail(R.drawable.ic_error)
			.resetViewBeforeLoading(true)
			.cacheOnDisk(true)
			.imageScaleType(ImageScaleType.EXACTLY)
			.bitmapConfig(Bitmap.Config.RGB_565)
			.considerExifParams(true)
			.displayer(new FadeInBitmapDisplayer(300))
			.build();
}