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; }
@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(); }
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; }
public Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options) { if (options == null) { options = this.configuration.defaultDisplayImageOptions; } options = new Builder().cloneFrom(options).syncLoading(false).build(); SyncImageLoadingListener listener = new SyncImageLoadingListener(); loadImage(uri, targetImageSize, options, listener); return listener.getLoadedBitmap(); }
public Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options) { if (options == null) { options = this.configuration.defaultDisplayImageOptions; } options = new Builder().cloneFrom(options).syncLoading(true).build(); SyncImageLoadingListener listener = new SyncImageLoadingListener(); loadImage(uri, targetImageSize, options, listener); return listener.getLoadedBitmap(); }
private void initDisplayOptions() { Builder builder = new Builder(); builder.bitmapConfig(Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY).cacheInMemory (true).cacheOnDisk(true).showImageForEmptyUri((int) R.color.in).showImageOnFail( (int) R.color.in).showImageOnLoading((int) R.color.in); this.mDisplayOptions = builder.build(); }
public static Builder getNormalOption_NotBuild(){ if(!initShowImage_Used){ throw new IllegalStateException("please first use initShowImage method !"); } Builder options = new DisplayImageOptions.Builder(); if (imageOnLoading!=-1) { options.showImageOnLoading(imageOnLoading); } if (imageForEmptyUri!=-1) { options.showImageForEmptyUri(imageForEmptyUri); } if (imageOnFail!=-1) { options.showImageOnFail(imageOnFail); } options.imageScaleType(ImageScaleType.IN_SAMPLE_INT); options.cacheInMemory(true); options.cacheOnDisk(true); options.bitmapConfig(Bitmap.Config.RGB_565); // 设置图片的解码类型 // ------------------------可扩展的东西------------------------------- // options.considerExifParams(true); //是否考虑JPEG图像EXIF参数(旋转,翻转) // options.decodingOptions(BitmapFactory.Options decodingOptions);//设置图片的解码配置 // options.delayBeforeLoading(0);//int delayInMillis为你设置的下载前的延迟时间 // options.resetViewBeforeLoading(true);//设置图片在下载前是否重置,复位 // options.displayer(new RoundedBitmapDisplayer(20))//不推荐用 因为会重新生成 ARGB8888 的图片!!!!是否设置为圆角,弧度为多少 // options.displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间,可能会出现闪动 return options; }
private static final DisplayImageOptions getDisplayOptions(JSONObject item, boolean preProcess){ Builder displayOptions = new DisplayImageOptions.Builder() .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) .cacheInMemory() .cacheOnDisc(); return displayOptions.build(); }
public void init(Context context, LetvThumbnailUtils letvThumbnailUtils) { LetvCacheConfiguration.initCacheLibrary(context, letvThumbnailUtils); this.options = new Builder().cacheInMemory(true).cacheOnDisk(true).resetViewBeforeLoading(false).displayer(new SimpleBitmapDisplayer()).bitmapConfig(Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build(); }
public static DisplayImageOptions avatar() { return new Builder().cacheOnDisc(true).showImageOnLoading((int) R.drawable.aa0) .showImageOnFail((int) R.drawable.aa0).cacheInMemory(true).considerExifParams (true).showImageForEmptyUri((int) R.drawable.aa0).bitmapConfig(Config .RGB_565).build(); }
public static DisplayImageOptions global(int drawableId) { return new Builder().cacheInMemory(true).cacheOnDisc(true).considerExifParams(true) .showImageOnLoading(drawableId).showImageOnFail(drawableId).showImageForEmptyUri (drawableId).imageScaleType(ImageScaleType.IN_SAMPLE_INT).bitmapConfig (Config.ARGB_8888).build(); }
public static DisplayImageOptions global(Drawable drawable) { return new Builder().cacheInMemory(true).cacheOnDisc(true).considerExifParams(true) .showImageOnLoading(drawable).showImageOnFail(drawable).showImageForEmptyUri (drawable).imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Config .ARGB_8888).build(); }
public static DisplayImageOptions uchoiceOption() { return new Builder().showImageOnLoading((int) R.drawable.l_).showImageOnFail((int) R .drawable.mh).cacheInMemory(false).cacheOnDisc(true).showImageForEmptyUri((int) R .drawable.mh).imageScaleType(ImageScaleType.IN_SAMPLE_INT).bitmapConfig(Config .ARGB_8888).build(); }
public static DisplayImageOptions noImage() { return new Builder().cacheOnDisc(true).build(); }