/**获取配置 * @param cornerRadiusSize * @param defaultImageResId * @return */ @SuppressWarnings("deprecation") private static DisplayImageOptions getOption(int cornerRadiusSize, int defaultImageResId) { Options options0 = new Options(); options0.inPreferredConfig = Bitmap.Config.RGB_565; DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder(); if(defaultImageResId > 0) { try { builder.showImageForEmptyUri(defaultImageResId) .showImageOnLoading(defaultImageResId) .showImageOnFail(defaultImageResId); } catch (Exception e) { Log.e(TAG, "getOption try {builder.showImageForEmptyUri(defaultImageResId) ..." + " >> } catch (Exception e) { \n" + e.getMessage()); } } if (cornerRadiusSize > 0) { builder.displayer(new RoundedBitmapDisplayer(cornerRadiusSize)); } return builder.cacheInMemory(true).cacheOnDisc(true).decodingOptions(options0).build(); }
@SuppressWarnings("deprecation") private void initImageLoader() { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( this) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions .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 .discCacheSize(50 * 1024 * 1024) // 缓冲大小 .discCacheFileCount(100) // 缓冲文件数目 .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(this)) // default .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .writeDebugLogs().build(); // 2.单例ImageLoader类的初始化 ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.init(config); }
public static ImageLoader getImageLoader(Context context) { if (sImageLoader == null) { DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder() .showImageOnLoading(Drawables.sPlaceholderDrawable) .showImageOnFail(Drawables.sErrorDrawable) .cacheInMemory(true) .cacheOnDisk(true) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .defaultDisplayImageOptions(displayImageOptions) .diskCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE) .memoryCacheSize(ConfigConstants.MAX_MEMORY_CACHE_SIZE) .build(); sImageLoader = ImageLoader.getInstance(); sImageLoader.init(config); } return sImageLoader; }
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) { this.imageKey = imageKey; this.imageUri = imageUri; this.originalImageUri = originalImageUri; this.targetSize = targetSize; this.imageScaleType = displayOptions.getImageScaleType(); this.viewScaleType = viewScaleType; this.downloader = downloader; this.extraForDownloader = displayOptions.getExtraForDownloader(); considerExifParams = displayOptions.isConsiderExifParams(); decodingOptions = new Options(); copyOptions(displayOptions.getDecodingOptions(), decodingOptions); }
/** * 获取一个圆形的配置 * * @return */ public static DisplayImageOptions getCircleOption(Integer strokeColor, float strokeWidth) { DisplayImageOptions options = new DisplayImageOptions.Builder() . // 网络图片下载完成之前的预加载的默认图片 showImageOnLoading(R.mipmap.ic_launcher) . // 网络图片下载失败后显示该默认图片 showImageOnFail(R.mipmap.ic_launcher) . // 图片的质量 bitmapConfig(Bitmap.Config.RGB_565).cacheInMemory(true) .cacheOnDisk(true) .displayer(new CircleBitmapDisplayer(strokeColor, strokeWidth)) .build(); return options; }
@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; }
/** * 获取一个默认的配置 * * @return */ public static DisplayImageOptions getDefaultOption() { DisplayImageOptions options = new DisplayImageOptions.Builder() . // 网络图片下载完成之前的预加载的默认图片 showImageOnLoading(R.mipmap.ic_launcher) . // 网络图片下载失败后显示该默认图片 showImageOnFail(R.mipmap.ic_launcher) . // 图片的质量 bitmapConfig(Bitmap.Config.RGB_565).cacheInMemory(true) .cacheOnDisk(true).build(); return options; }
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(); }
private void loadImageAndExtractColour(@NonNull ImageLoader loader, @NonNull DisplayImageOptions imageOptions, String url) { loader.loadImage(url, imageOptions, new ImageLoadingAdapter() { @Override public void onLoadingComplete(String imageUri, View view, final Bitmap loadedImage) { if (loadedImage != null) { new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { if (palette != null) { setColorAndAnimateChange(palette.getDominantColor(Color.LTGRAY)); } } }); } } }); }
@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(); }
/** * 获取图片加载器的图片的配置 * * @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(); }
/** * ImageLoader组件加载图片默认配置 * 显示大量的图片,当我们快速滑动GridView,ListView,希望能停止图片的加载时使用如下设置: * listView.setOnScrollListener(new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling)); * gridView.setOnScrollListener(new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling)); * * @param loadingId * @param failId * @param cacheOnMemory * @param cacheOnDinsk * @return */ public static DisplayImageOptions getImageLoaderOptions(int loadingId, int failId, boolean cacheOnMemory, boolean cacheOnDinsk) { DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(loadingId) //如果不需要设置则传0,设置该值刷新的时候会有闪烁现象 .showImageForEmptyUri(failId) // 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(failId) // 设置图片加载或解码过程中发生错误显示的图片 .cacheInMemory(cacheOnMemory) // default 设置下载的图片是否缓存在内存中 .cacheOnDisk(cacheOnDinsk) // default 设置下载的图片是否缓存在SD卡中 .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型 // .resetViewBeforeLoading(true) // default 设置图片在加载前是否重置、复位 // .delayBeforeLoading(1000) // 下载前的延迟时间 // .preProcessor(...) // .postProcessor(...) // .extraForDownloader(...) // .considerExifParams(false) // default // .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default 设置图片以如何的编码方式显示 // .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型 // .decodingOptions(...) // 图片的解码设置 // .displayer(new SimpleBitmapDisplayer()) // default 还可以设置圆角图片new RoundedBitmapDisplayer(20) // .handler(new Handler()) // default .build(); return options; }
@Override public void onBindViewHolder(ItemHolder itemHolder, int i) { Song localItem = arraylist.get(i); itemHolder.title.setText(localItem.title); itemHolder.artist.setText(localItem.artistName); if (MusicPlayer.getCurrentAudioId() == localItem.id) { itemHolder.title.setTextColor(Config.accentColor(mContext, ateKey)); if (MusicPlayer.isPlaying()) { itemHolder.visualizer.setColor(Config.accentColor(mContext, ateKey)); itemHolder.visualizer.setVisibility(View.VISIBLE); } } else { itemHolder.title.setTextColor(Config.textColorPrimary(mContext, ateKey)); itemHolder.visualizer.setVisibility(View.GONE); } ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build()); setOnPopupMenuListener(itemHolder, i); }
@Override public void onBindViewHolder(ItemHolder itemHolder, int i) { Album localItem = arraylist.get(i); itemHolder.title.setText(localItem.title); String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount); itemHolder.details.setText(songCount); ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true) .showImageOnFail(R.drawable.ic_empty_music2) .resetViewBeforeLoading(true) .build()); if (TimberUtils.isLollipop()) itemHolder.albumArt.setTransitionName("transition_album_art" + i); }
@Override public void onBindViewHolder(ItemHolder itemHolder, int i) { if (getItemViewType(i) == 0) { //nothing setUpAlbums(itemHolder.albumsRecyclerView); } else { Song localItem = arraylist.get(i); itemHolder.title.setText(localItem.title); itemHolder.album.setText(localItem.albumName); ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build()); setOnPopupMenuListener(itemHolder, i - 1); } }
private void initImageLoader() { File cacheDir = com.nostra13.universalimageloader.utils.StorageUtils .getOwnCacheDirectory(getActivity(), IMAGE_CACHE_PATH); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true).cacheOnDisc(true).build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getActivity()).defaultDisplayImageOptions(defaultOptions) .memoryCache(new LruMemoryCache(12 * 1024 * 1024)) .memoryCacheSize(12 * 1024 * 1024) .discCacheSize(32 * 1024 * 1024).discCacheFileCount(100) .discCache(new UnlimitedDiscCache(cacheDir)) .threadPriority(Thread.NORM_PRIORITY - 2) .tasksProcessingOrder(QueueProcessingType.LIFO).build(); ImageLoader.getInstance().init(config); }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions() { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_account_circle) .showImageForEmptyUri(R.drawable.ic_account_circle) .showImageOnFail(R.drawable.ic_account_circle) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .decodingOptions(op) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .build(); return options; }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions(int defaultIconId) { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(defaultIconId) .showImageForEmptyUri(defaultIconId) .showImageOnFail(defaultIconId) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .decodingOptions(op) .build(); return options; }
/** * 图片显示配置 * * @return */ public static DisplayImageOptions getImageLoaderOptions(int loadingImgId, int emptyUriImgId, int failImgId) { BitmapFactory.Options op = new BitmapFactory.Options(); op.inSampleSize = 4; DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(loadingImgId) .showImageForEmptyUri(emptyUriImgId) .showImageOnFail(failImgId) .bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer(new FadeInBitmapDisplayer(animTime)) // 设置动画淡入效果 .decodingOptions(op) .build(); return options; }
/** * 获取一个渐显图片的配置 * * @return */ public static DisplayImageOptions getFadeInOption(int durationMillis, boolean animateFromNetwork, boolean animateFromDisk, boolean animateFromMemory) { DisplayImageOptions options = new DisplayImageOptions.Builder() . // 网络图片下载完成之前的预加载的默认图片 showImageOnLoading(R.mipmap.ic_launcher) . // 网络图片下载失败后显示该默认图片 showImageOnFail(R.mipmap.ic_launcher) . // 图片的质量 bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer( new FadeInBitmapDisplayer(durationMillis, animateFromNetwork, animateFromDisk, animateFromMemory)).build(); return options; }
private void initImageLoader() { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .threadPoolSize(5) .threadPriority(Thread.NORM_PRIORITY - 2) .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(2 * 1024)) .memoryCacheSize(2 * 1024) .defaultDisplayImageOptions(new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.no_photo_group) .showImageOnFail(R.drawable.no_photo_group) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(300)).build()) .tasksProcessingOrder(QueueProcessingType.LIFO).build(); ImageLoader.getInstance().init(config); com.nostra13.universalimageloader.utils.L.writeLogs(false); }
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()); }
/** * 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; }
/** * 初始化图片载入框架 */ private void initImageLoader() { File cacheDir = StorageUtils.getCacheDirectory(this); int MAXMEMONRY = (int) (Runtime.getRuntime().maxMemory()); // System.out.println("dsa-->"+MAXMEMONRY+" "+(MAXMEMONRY/5));//.memoryCache(new // LruMemoryCache(50 * 1024 * 1024)) DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisk(true) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( this).memoryCacheExtraOptions(480, 800).defaultDisplayImageOptions(defaultOptions) .diskCacheExtraOptions(480, 800, null).threadPoolSize(3) .threadPriority(Thread.NORM_PRIORITY - 2) .tasksProcessingOrder(QueueProcessingType.FIFO) .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(MAXMEMONRY / 5)) .diskCache(new UnlimitedDiskCache(cacheDir)) .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(this)) // default .imageDecoder(new BaseImageDecoder(false)) // default .defaultDisplayImageOptions(DisplayImageOptions.createSimple()).build(); ImageLoader.getInstance().init(config); }
/** * 获取一个圆角的配置 * * @return */ public static DisplayImageOptions getRoundBitmapOption( int cornerRadiusPixels, int marginPixels) { DisplayImageOptions options = new DisplayImageOptions.Builder() . // 网络图片下载完成之前的预加载的默认图片 showImageOnLoading(R.mipmap.ic_launcher) . // 网络图片下载失败后显示该默认图片 showImageOnFail(R.mipmap.ic_launcher) . // 图片的质量 bitmapConfig(Bitmap.Config.RGB_565) .cacheInMemory(true) .cacheOnDisk(true) .displayer( new RoundedBitmapDisplayer(cornerRadiusPixels, marginPixels)).build(); return options; }
/** * 为ImageView设置图片 * * @param viewId * @return */ public ViewHolder setImageByUrl(int viewId, String url) { ImageView iv = getView(viewId); DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.mipmap.ic_launcher) .showImageOnFail(R.mipmap.ic_launcher) // 设置图片质量 .bitmapConfig(Bitmap.Config.RGB_565) // 设置内存缓存 .cacheInMemory(true) // 设置磁盘缓存 .cacheOnDisk(true) // 设置图片特效 .displayer(new FadeInBitmapDisplayer(300)).build(); ImageLoader.getInstance().displayImage(url,iv, ImageLoaderUtil.getFadeInOption(200,true,true,true)); return this; }
public static DisplayImageOptions getAvatarOptions2(int corner,int defaultRes){ try { if (defaultRes <= 0) { defaultRes = R.drawable.tt_default_user_portrait_corner; } if (avatarOptionsMaps.containsKey(defaultRes)) { Map<Integer, DisplayImageOptions> displayOption = avatarOptionsMaps.get(defaultRes); if (displayOption.containsKey(corner)) { return displayOption.get(corner); } } DisplayImageOptions newDisplayOption = null; if (corner==CIRCLE_CORNER) { newDisplayOption = new DisplayImageOptions.Builder() .showImageOnFail(defaultRes) .cacheInMemory(true) .build(); } else { if (corner < 0) { corner = 0; } newDisplayOption = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisk(true) .build(); } Map<Integer, DisplayImageOptions> cornerDisplayOptMap = new HashMap<Integer, DisplayImageOptions>(); cornerDisplayOptMap.put(corner, newDisplayOption); avatarOptionsMaps.put(defaultRes, cornerDisplayOptMap); return newDisplayOption; }catch (Exception e){ logger.e(e.toString()); return null; } }
ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_stub) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .build(); }
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(); }
ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_stub) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new RoundedBitmapDisplayer(20)) .build(); }
ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_stub) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .displayer(new CircleBitmapDisplayer(Color.WHITE, 5)) .build(); }
/** * @return void * @Title: initImageLoader * @Description: TODO */ private void initImageLoader() { DisplayImageOptions imageOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.default_background) .showImageOnFail(R.drawable.default_background) .cacheInMemory(true).cacheOnDisk(true) .resetViewBeforeLoading(true).considerExifParams(false) .bitmapConfig(Bitmap.Config.RGB_565).build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .memoryCacheExtraOptions(480, 800) .diskCacheExtraOptions(480, 800, null) .threadPoolSize(5) .threadPriority(Thread.NORM_PRIORITY) .tasksProcessingOrder(QueueProcessingType.LIFO) .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) .memoryCacheSize(2 * 1024 * 1024) .memoryCacheSizePercentage(10) // .diskCache( // new UnlimitedDiscCache(StorageUtils.getCacheDirectory( // this, true))) .diskCacheSize(50 * 1024 * 1024).diskCacheFileCount(100) .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) .imageDownloader(new BaseImageDownloader(this)) .imageDecoder(new BaseImageDecoder(false)) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .defaultDisplayImageOptions(imageOptions).build(); ImageLoader.getInstance().init(config); }
public SmileyFragment() { // Required empty public constructor iop = new DisplayImageOptions.Builder() .cacheOnDisk(true) .bitmapConfig(Bitmap.Config.RGB_565) // not much quality needed .build(); }
public void loadImageAndDisplay(@NonNull ImageLoader loader, @NonNull DisplayImageOptions imageOptions, @Nullable String featureImageToShow, @Nullable String fallbackImageToExtractColours) { setColour(ContextCompat.getColor(getContext(), R.color.fdroid_blue)); if (!TextUtils.isEmpty(featureImageToShow)) { loadImageAndDisplay(loader, imageOptions, featureImageToShow); } else if (!TextUtils.isEmpty(fallbackImageToExtractColours)) { loadImageAndExtractColour(loader, imageOptions, fallbackImageToExtractColours); } }
public void loadImageAndDisplay(@NonNull ImageLoader loader, @NonNull DisplayImageOptions imageOptions, String url) { loader.loadImage(url, imageOptions, new ImageLoadingAdapter() { @Override public void onLoadingComplete(String imageUri, View view, final Bitmap loadedImage) { if (loadedImage != null) { setImageBitmap(loadedImage); } } }); }
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); }