com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer Java Examples
The following examples show how to use
com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLoaderUtils.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 获取 ImageLoader 图片加载配置 * @param isCache 是否缓存在内存中 * @param isCacheDisk 是否保存在 SDCard * @param loadingRes 设置加载中显示的图片 * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getCacheImageOptions(final boolean isCache, final boolean isCacheDisk, @DrawableRes final int loadingRes) { DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder() .imageScaleType(ImageScaleType.EXACTLY) // 设置图片缩放 .bitmapConfig(Bitmap.Config.RGB_565) // 图片解码类型 .cacheInMemory(isCache) // 是否保存到内存 .displayer(new RoundedBitmapDisplayer(20)) .cacheOnDisk(isCacheDisk); // 是否保存到 SDCard 上 // 判断是否使用加载图片 if (loadingRes != 0) { builder.showImageOnLoading(loadingRes) // 设置图片在下载期间显示的图片 .showImageForEmptyUri(loadingRes) // 设置图片 Uri 为空或是错误的时候显示的图片 .showImageOnFail(loadingRes); // 设置图片 ( 加载 / 解码 ) 过程中错误时候显示的图片 } return builder.build(); }
Example #2
Source File: DisplayConfig.java From TestChat with Apache License 2.0 | 6 votes |
/** * 获取图片加载器的图片的配置 * * @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 #3
Source File: LoadAndDisplayImageTask.java From mobile-manager-tool with MIT License | 6 votes |
private void fireFailEvent(final FailType failType, final Throwable failCause) { if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return; Runnable r = new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { Bitmap bitmapOnFaile = options.getImageBitmapOnFail(configuration.resources); if (options.getDisplayer() instanceof RoundedBitmapDisplayer && bitmapOnFaile != null) { int corner = ((RoundedBitmapDisplayer) options.getDisplayer()).getRoundedBitmapCorner(); if (corner != 0) { imageAware.setImageDrawable(new RoundedBitmapDisplayer.RoundedDrawable(bitmapOnFaile, corner, 0)); } } else { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; runTask(r, false, handler, engine); }
Example #4
Source File: ImageLoaderUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取圆角图片加载配置 * @param options {@link DisplayImageOptions} * @param cornerRadiusPixels 圆角大小 * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getRoundedBitmapDisplayer(final DisplayImageOptions options, final int cornerRadiusPixels) { if (options != null) { return getBitmapDisplayerOptions(options, new RoundedBitmapDisplayer(cornerRadiusPixels)); } return options; }
Example #5
Source File: ImageLoaders.java From LLApp with Apache License 2.0 | 5 votes |
public static void setheadimg(int dis, String url, ImageView imageView) { if (options == null) { options = new DisplayImageOptions.Builder().showImageOnLoading(0) .showImageForEmptyUri(0).showImageOnFail(0) .cacheInMemory(true).cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedBitmapDisplayer(dis)).build(); } ImageLoader.getInstance().displayImage(url, imageView, options); }
Example #6
Source File: ImageLoaders.java From LLApp with Apache License 2.0 | 5 votes |
public static void settopimg(int dis, String url, ImageView imageView) { if (optionstop == null) { optionstop = new DisplayImageOptions.Builder() .showImageOnLoading(0).showImageForEmptyUri(0) .showImageOnFail(0).cacheInMemory(true).cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedBitmapDisplayer(dis)).build(); } ImageLoader.getInstance().displayImage(url, imageView, optionstop); }
Example #7
Source File: ImageLoaderHelper.java From SimplifyReader with Apache License 2.0 | 5 votes |
public DisplayImageOptions getDisplayOptions(int round) { return new DisplayImageOptions.Builder() .cacheInMemory(true) .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedBitmapDisplayer(DensityUtils.dip2px(mContext, round))) .build(); }
Example #8
Source File: ImageLoaderHelper.java From SimplifyReader with Apache License 2.0 | 5 votes |
public DisplayImageOptions getDisplayOptions(int round, Drawable drawable) { return new DisplayImageOptions.Builder() .showImageOnLoading(drawable) .showImageForEmptyUri(drawable) .showImageOnFail(drawable) .cacheInMemory(true) .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisk(true) .considerExifParams(true) .displayer(new RoundedBitmapDisplayer(DensityUtils.dip2px(mContext, round))) .build(); }
Example #9
Source File: ContentActivity.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_lay); options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.icon_image) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error).cacheInMemory() .cacheOnDisc().displayer(new RoundedBitmapDisplayer(20)) .build(); initView(); // setAnimation(); }
Example #10
Source File: ImageGalleryFragment.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 5 votes |
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(); }
Example #11
Source File: ImageLoaderUtil.java From sctalk with Apache License 2.0 | 4 votes |
public static DisplayImageOptions getAvatarOptions(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) .showImageForEmptyUri(defaultRes) .cacheInMemory(true) .resetViewBeforeLoading(true) .displayer(new CircleBitmapDisplayer()) .build(); } else { if (corner < 0) { corner = 0; } newDisplayOption = new DisplayImageOptions.Builder() .showImageOnLoading(defaultRes) .showImageForEmptyUri(defaultRes) .showImageOnFail(defaultRes) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(false) // .displayer(new FadeInBitmapDisplayer(200)) .displayer(new RoundedBitmapDisplayer(corner)) .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; } }
Example #12
Source File: IMUIHelper.java From sctalk with Apache License 2.0 | 4 votes |
public static void displayImage(ImageView imageView, String resourceUri, int defaultResId, int roundPixel) { Logger logger = Logger.getLogger(IMUIHelper.class); logger.d("displayimage#displayImage resourceUri:%s, defeaultResourceId:%d", resourceUri, defaultResId); if (resourceUri == null) { resourceUri = ""; } boolean showDefaultImage = !(defaultResId <= 0); if (TextUtils.isEmpty(resourceUri) && !showDefaultImage) { logger.e("displayimage#, unable to display image"); return; } DisplayImageOptions options; if (showDefaultImage) { options = new DisplayImageOptions.Builder(). showImageOnLoading(defaultResId). showImageForEmptyUri(defaultResId). showImageOnFail(defaultResId). cacheInMemory(true). cacheOnDisk(true). considerExifParams(true). displayer(new RoundedBitmapDisplayer(roundPixel)). imageScaleType(ImageScaleType.EXACTLY).// 改善OOM bitmapConfig(Bitmap.Config.RGB_565).// 改善OOM build(); } else { options = new DisplayImageOptions.Builder(). cacheInMemory(true). cacheOnDisk(true). // considerExifParams(true). // displayer(new RoundedBitmapDisplayer(roundPixel)). // imageScaleType(ImageScaleType.EXACTLY).// 改善OOM // bitmapConfig(Bitmap.Config.RGB_565).// 改善OOM build(); } ImageLoader.getInstance().displayImage(resourceUri, imageView, options, null); }
Example #13
Source File: IMUIHelper.java From sctalk with Apache License 2.0 | 4 votes |
public static void displayImageNoOptions(ImageView imageView, String resourceUri, int defaultResId, int roundPixel) { Logger logger = Logger.getLogger(IMUIHelper.class); logger.d("displayimage#displayImage resourceUri:%s, defeaultResourceId:%d", resourceUri, defaultResId); if (resourceUri == null) { resourceUri = ""; } boolean showDefaultImage = !(defaultResId <= 0); if (TextUtils.isEmpty(resourceUri) && !showDefaultImage) { logger.e("displayimage#, unable to display image"); return; } DisplayImageOptions options; if (showDefaultImage) { options = new DisplayImageOptions.Builder(). showImageOnLoading(defaultResId). showImageForEmptyUri(defaultResId). showImageOnFail(defaultResId). cacheInMemory(true). cacheOnDisk(true). considerExifParams(true). displayer(new RoundedBitmapDisplayer(roundPixel)). imageScaleType(ImageScaleType.EXACTLY).// 改善OOM bitmapConfig(Bitmap.Config.RGB_565).// 改善OOM build(); } else { options = new DisplayImageOptions.Builder(). // cacheInMemory(true). // cacheOnDisk(true). imageScaleType(ImageScaleType.EXACTLY).// 改善OOM bitmapConfig(Bitmap.Config.RGB_565).// 改善OOM build(); } ImageLoader.getInstance().displayImage(resourceUri, imageView, options, null); }
Example #14
Source File: ImageLoadUtil.java From mobile-manager-tool with MIT License | 4 votes |
public static void loadRoundImage(ImageView imageView, String url, int defaultImg) { loadImage(imageView, url, defaultImg, 0, 0, true, new RoundedBitmapDisplayer(5)); }
Example #15
Source File: ImageLoaderUtils.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 获取圆角图片加载配置 * @param cornerRadiusPixels 圆角大小 * @return {@link DisplayImageOptions} */ public static DisplayImageOptions getRoundedBitmapDisplayer(final int cornerRadiusPixels) { return getBitmapDisplayerOptions(cloneImageOptions(DF_OPTIONS).build(), new RoundedBitmapDisplayer(cornerRadiusPixels)); }