Java 类com.nostra13.universalimageloader.core.assist.ImageScaleType 实例源码

项目:GitHub    文件:BaseImageDecoder.java   
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;
}
项目:mobile-store    文件:ScreenShotsActivity.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.NONE)
            .showImageOnLoading(R.drawable.screenshot_placeholder)
            .showImageForEmptyUri(R.drawable.screenshot_placeholder)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    View rootView = inflater.inflate(R.layout.activity_screenshots_page, container, false);

    ImageView screenshotView = (ImageView) rootView.findViewById(R.id.screenshot);
    ImageLoader.getInstance().displayImage(screenshotUrl, screenshotView, displayImageOptions);

    return rootView;
}
项目:mobile-store    文件:CategoryController.java   
CategoryController(final Activity activity, LoaderManager loaderManager, View itemView) {
    super(itemView);

    this.activity = activity;
    this.loaderManager = loaderManager;

    appCardsAdapter = new AppPreviewAdapter(activity);

    viewAll = (Button) itemView.findViewById(R.id.button);
    viewAll.setOnClickListener(onViewAll);

    heading = (TextView) itemView.findViewById(R.id.name);
    image = (FeatureImage) itemView.findViewById(R.id.category_image);
    background = (FrameLayout) itemView.findViewById(R.id.category_background);

    RecyclerView appCards = (RecyclerView) itemView.findViewById(R.id.app_cards);
    appCards.setAdapter(appCardsAdapter);
    appCards.addItemDecoration(new ItemDecorator(activity));

    displayImageOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .imageScaleType(ImageScaleType.NONE)
            .displayer(new FadeInBitmapDisplayer(100, true, true, false))
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
}
项目:TYT    文件:SelectPictureActivity.java   
@Override
public void onAfterViews() {
    initToolbar();

    mContext = this;
    mContentResolver = getContentResolver();

    mImageLoader = ImageLoader.getInstance();
    options = new DisplayImageOptions.Builder()
            .showImageOnLoading(R.mipmap.ic_launcher)
            .showImageForEmptyUri(R.mipmap.ic_launcher)
            .showImageOnFail(R.mipmap.ic_launcher)
            .cacheInMemory(false)
            .cacheOnDisk(true)
            .considerExifParams(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565).build();

    initViews();
}
项目:TestChat    文件:DisplayConfig.java   
/**
         * 获取图片加载器的图片的配置
         *
         * @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();
        }
项目:letv    文件:DisplayImageOptions.java   
public Builder() {
    this.imageResOnLoading = 0;
    this.imageResForEmptyUri = 0;
    this.imageResOnFail = 0;
    this.imageOnLoading = null;
    this.imageForEmptyUri = null;
    this.imageOnFail = null;
    this.resetViewBeforeLoading = false;
    this.cacheInMemory = false;
    this.cacheOnDisk = false;
    this.imageScaleType = ImageScaleType.IN_SAMPLE_POWER_OF_2;
    this.decodingOptions = new Options();
    this.delayBeforeLoading = 0;
    this.considerExifParams = false;
    this.extraForDownloader = null;
    this.preProcessor = null;
    this.postProcessor = null;
    this.displayer = DefaultConfigurationFactory.createBitmapDisplayer();
    this.handler = null;
    this.isSyncLoading = false;
    this.decodingOptions.inPurgeable = true;
    this.decodingOptions.inInputShareable = true;
}
项目:letv    文件:LoadAndDisplayImageTask.java   
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;
}
项目:letv    文件:BaseImageDecoder.java   
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;
}
项目:letv    文件:TitlePopupMenu.java   
@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();
}
项目:ShortcutMenu    文件:BitmapOptions.java   
/**
 * ListView GridView RecyclerView时 ImageLoader使用该配置
 * @param image_default
 * @return
 */
public static DisplayImageOptions getListDisplayImageOptions(int image_default) {
    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
    DisplayImageOptions options=builder
            //.showImageOnLoading(R.drawable.loading) //设置图片在下载期间显示的图片
            .showImageForEmptyUri(image_default)//设置图片Uri为空或是错误的时候显示的图片
            .showImageOnFail(image_default)  //设置图片加载/解码过程中错误时候显示的图片
            .cacheInMemory(true)//设置下载的图片是否缓存在内存中
            .cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中
            .considerExifParams(true)  //是否考虑JPEG图像EXIF参数(旋转,翻转)
            .imageScaleType(ImageScaleType.EXACTLY)//设置图片以如何的编码方式显示
            .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型
            //.decodingOptions(BitmapFactory.Options decodingOptions)//设置图片的解码配置
            .delayBeforeLoading(0)//int delayInMillis为你设置的下载前的延迟时间
            //设置图片加入缓存前,对bitmap进行设置
            //.preProcessor(BitmapProcessor preProcessor)
            .resetViewBeforeLoading(false)//设置图片在下载前是否重置,复位
            //.displayer(new RoundedBitmapDisplayer(20))//不推荐用!!!!是否设置为圆角,弧度为多少
            //.displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间,可能会出现闪动
            .build();//构建完成
    return options;
}
项目:GifImageLoader    文件:BaseImageDecoder.java   
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;
}
项目:boohee_v5.6    文件:LoadAndDisplayImageTask.java   
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;
}
项目:boohee_v5.6    文件:BaseImageDecoder.java   
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;
}
项目:ImageLoaderSupportGif    文件:BaseImageDecoder.java   
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;
}
项目:OpenEyesReading-android    文件:App.java   
public static void initImageLoader(Context context) {
    b = new DisplayImageOptions.Builder();
    b.cacheOnDisc(true)
            .cacheInMemory(false)
            .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
            .bitmapConfig(Bitmap.Config.RGB_565);
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.discCacheFileNameGenerator(new Md5FileNameGenerator());
    config.memoryCacheSize(20 * 1024 * 1024); // 20 MiB
    config.discCacheSize(100 * 1024 * 1024); // 100 MiB
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    config.defaultDisplayImageOptions(b.build());
    config.writeDebugLogs();
    ImageLoader.getInstance().init(config.build());
}
项目:TAG    文件:DemoApplication.java   
private void initImageLoader() {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisk(true)
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .defaultDisplayImageOptions(defaultOptions)
            .denyCacheImageMultipleSizesInMemory()
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, Constant.APP_IMAGE)))
            .diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO)
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024)
            .threadPoolSize(3)
            .build();
    ImageLoader.getInstance().init(config);
}
项目:WliveTV    文件:BaseDataAdapter.java   
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);
    }
}
项目:CloudMusic    文件:ToolImage.java   
/**
     * 获取渐现显示选项
     * @return
     */
    public static DisplayImageOptions getFadeOptions() {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(null) // 设置图片下载期间显示的图片
                .showImageForEmptyUri(null) // 设置图片Uri为空或是错误的时候显示的图片
                .showImageOnFail(null) // 设置图片加载或解码过程中发生错误显示的图片
                .cacheInMemory(true) // 设置下载的图片是否缓存在内存中
                .cacheOnDisk(true) // 设置下载的图片是否缓存在SD卡中
                        /**设置图片缩放方式:
                         EXACTLY :图像将完全按比例缩小到目标大小
                         EXACTLY_STRETCHED:图片会缩放到目标大小完全
                         IN_SAMPLE_INT:图像将被二次采样的整数倍
                         IN_SAMPLE_POWER_OF_2:图片将降低2倍,直到下一减少步骤,使图像更小的目标大小
                         NONE:图片不会调整
                         ***/
                .imageScaleType(ImageScaleType.NONE)
                .bitmapConfig(Bitmap.Config.RGB_565)
//                .delayBeforeLoading(100)// 设置图片下载前的延迟
//                .displayer(new FadeInBitmapDisplayer(1 * 1000))// 渐显--设置图片渐显的时间
//                .displayer(new RoundedBitmapDisplayer(20)) // 设置成圆角图片
                .build(); // 构建完成
        return options;
    }
项目:yun2win-sdk-android    文件:BaseImageDecoder.java   
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;
}
项目:Trailer    文件:Image_Loader.java   
public DisplayImageOptions getDisplayOptions() {
    DisplayImageOptions options;
    options = new DisplayImageOptions.Builder()
            .showImageOnLoading(R.drawable.loading) // 设置图片在下载期间显示的图片
            .showImageForEmptyUri(R.drawable.load_fail)// 设置图片Uri为空或是错误的时候显示的图片
            .showImageOnFail(R.drawable.loading) // 设置图片加载/解码过程中错误时候显示的图片
            .cacheInMemory(true)// 设置下载的图片是否缓存在内存中
            .cacheOnDisk(true) //外存缓存
            .cacheOnDisc(true)// 设置下载的图片是否缓存在SD卡中
            .considerExifParams(true) // 是否考虑JPEG图像EXIF参数(旋转,翻转)
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// 设置图片以如何的编码方式显示
            .bitmapConfig(Bitmap.Config.RGB_565)// 设置图片的解码类型//
            // .delayBeforeLoading(int delayInMillis)//int
            // delayInMillis为你设置的下载前的延迟时间
            // 设置图片加入缓存前,对bitmap进行设置
            // .preProcessor(BitmapProcessor preProcessor)
            .resetViewBeforeLoading(true)// 设置图片在下载前是否重置,复位
           // .displayer(new RoundedBitmapDisplayer(20))// 是否设置为圆角,弧度为多少
            .displayer(new FadeInBitmapDisplayer(50))// 是否图片加载好后渐入的动画时间
            .build();// 构建完成
    return options;
}
项目:SmartFace    文件:App.java   
private void initImageLoader() {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisk(true)
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .defaultDisplayImageOptions(defaultOptions)
            .denyCacheImageMultipleSizesInMemory()
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, AppConstants.APP_IMAGE)))
            .diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO)
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024)
            .threadPoolSize(3)
            .build();
    ImageLoader.getInstance().init(config);
}
项目:XRichText    文件:UILKit.java   
/**
 * 初始化
 *
 * @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();
}
项目:smile-mvp    文件:UILImageLoader.java   
/**
     * 获取配置器
     * @param isCircle
     * @param defaultRes
     * @return
     */
    public DisplayImageOptions getDefaultOptions(boolean isCircle, int defaultRes){
        DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder()
                .cacheInMemory(true)//设置下载的图片是否缓存在内存中
                .cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中
                .considerExifParams(true)  //是否考虑JPEG图像EXIF参数(旋转,翻转)
                .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示
                .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型:设置为RGB565比起默认的ARGB_8888要节省大量的内存
//                .delayBeforeLoading(100)//载入图片前稍做延时可以提高整体滑动的流畅度
                .resetViewBeforeLoading(true);//设置图片在下载前是否重置,复位
                if(isCircle){
//                    builder.displayer(new RoundedBitmapDisplayer(12));//是否设置为圆角,弧度为多少
                    builder.displayer(new CircleBitmapDisplayer(10));
                }
                if(defaultRes!=0){
                    builder.showImageForEmptyUri(defaultRes)//设置图片Uri为空或是错误的时候显示的图片
//                            .showImageOnLoading(defaultRes) //设置图片在下载期间显示的图片-->应该去掉-会造成ListView中图片闪烁
                            .showImageOnFail(defaultRes);  //设置图片加载/解码过程中错误时候显示的图片
                }
        return builder.build();//构建完成
    }
项目:LLApp    文件:ImageLoaders.java   
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);
    }
项目:DdBanner    文件:ViewPagerActivity.java   
private void initViews() {
    options = new DisplayImageOptions.Builder()
            .showImageOnLoading(R.mipmap.ic_dd_default)
            .showImageOnFail(R.mipmap.ic_dd_default)
            .showImageForEmptyUri(R.mipmap.ic_dd_default)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    data = new ArrayList<>();
    data.add("http://i4.piimg.com/567571/1cb06f22d0abc62c.png");
    data.add("http://i4.piimg.com/567571/1cb06f22d0abc62c.png");
    data.add("http://i4.piimg.com/567571/1cb06f22d0abc62c.png");
    data.add("http://i4.piimg.com/567571/1cb06f22d0abc62c.png");

    viewPager.setAdapter(new TestAdapter());
}
项目:HPlayer    文件:Utility.java   
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;
}
项目:QQ    文件:MessageChatAdapter.java   
public MessageChatAdapter(Context context,List<BmobMsg> msgList) {
    // TODO Auto-generated constructor stub
    super(context, msgList);
    currentObjectId = BmobUserManager.getInstance(context).getCurrentUserObjectId();

    options = new DisplayImageOptions.Builder()
    .showImageForEmptyUri(R.drawable.ic_launcher)
    .showImageOnFail(R.drawable.ic_launcher)
    .resetViewBeforeLoading(true)
    .cacheOnDisc(true)
    .cacheInMemory(true)
    .imageScaleType(ImageScaleType.EXACTLY)
    .bitmapConfig(Bitmap.Config.RGB_565)
    .considerExifParams(true)
    .displayer(new FadeInBitmapDisplayer(300))
    .build();
}
项目:WliveTV    文件:BaseImageDecoder.java   
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;
}
项目:android-open-project-demo-master    文件:BaseImageDecoder.java   
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;
}
项目:mobile-manager-tool    文件:BaseImageDecoder.java   
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;
}
项目:ImageLoadingView    文件:MyApp.java   
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();
}
项目:AyoSunny    文件:BaseImageDecoder.java   
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;
}
项目:AyoSunny    文件:ImgPageActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_img_page);

    options = new DisplayImageOptions.Builder()
    .resetViewBeforeLoading(true)
    .cacheOnDisc(true)
    .imageScaleType(ImageScaleType.EXACTLY)
    .bitmapConfig(Bitmap.Config.RGB_565)
    .considerExifParams(true)
    .displayer(new FadeInBitmapDisplayer(0))
    .build();

    url=getIntent().getStringExtra("url");

    initView();
    initData();
}
项目:GitHub    文件:ImagePagerFragment.java   
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();
}
项目:GitHub    文件:LoadAndDisplayImageTask.java   
/** Decodes image file into Bitmap, resize it and save it back */
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    // Decode image file, compress and re-save it
    boolean saved = false;
    File targetFile = configuration.diskCache.get(uri);
    if (targetFile != null && targetFile.exists()) {
        ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
        DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
        ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey,
                Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE,
                getDownloader(), specialOptions);
        Bitmap bmp = decoder.decode(decodingInfo);
        if (bmp != null && configuration.processorForDiskCache != null) {
            L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
            bmp = configuration.processorForDiskCache.process(bmp);
            if (bmp == null) {
                L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
            }
        }
        if (bmp != null) {
            saved = configuration.diskCache.save(uri, bmp);
            bmp.recycle();
        }
    }
    return saved;
}
项目:GitHub    文件:BaseImageDecoder.java   
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;
}
项目:mobile-store    文件:ScreenShotsRecyclerViewAdapter.java   
ScreenShotsRecyclerViewAdapter(Context context, App app, Listener listener) {
    super();
    this.listener = listener;

    screenshots = app.getAllScreenshots(context);
    displayImageOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.NONE)
            .showImageOnLoading(R.drawable.screenshot_placeholder)
            .showImageForEmptyUri(R.drawable.screenshot_placeholder)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
}
项目:mobile-store    文件:Utils.java   
public static DisplayImageOptions.Builder getImageLoadingOptions() {
    return new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.NONE)
            .showImageOnLoading(R.drawable.ic_repo_app_default)
            .showImageForEmptyUri(R.drawable.ic_repo_app_default)
            .displayer(new FadeInBitmapDisplayer(200, true, true, false))
            .bitmapConfig(Bitmap.Config.RGB_565);
}
项目:Mire    文件:ImageConfig.java   
public static DisplayImageOptions.Builder getRawDefaultImageOptions()
{
       DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
       options.delayBeforeLoading(10).bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY);

    return options;
   }
项目:Mire    文件:ImageConfig.java   
public static DisplayImageOptions getWallpaperOptions() {
     DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
     options.delayBeforeLoading(10)
.bitmapConfig(Bitmap.Config.ARGB_8888)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.cacheOnDisk(false)
.cacheInMemory(false);
     return options.build();
 }