com.bumptech.glide.load.resource.bitmap.RoundedCorners Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.bitmap.RoundedCorners.
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: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private GlideRequest applySizing(@NonNull GlideRequest request, @NonNull BitmapTransformation fitting) { int[] size = new int[2]; fillTargetDimensions(size, dimens, bounds); if (size[WIDTH] == 0 && size[HEIGHT] == 0) { size[WIDTH] = getDefaultWidth(); size[HEIGHT] = getDefaultHeight(); } request = request.override(size[WIDTH], size[HEIGHT]); if (radius > 0) { return request.transforms(fitting, new RoundedCorners(radius)); } else { return request.transforms(fitting); } }
Example #2
Source File: GlideHelper.java From hipda with GNU General Public License v2.0 | 6 votes |
public static void loadAvatar(RequestManager glide, ImageView view, String avatarUrl) { avatarUrl = Utils.nullToText(avatarUrl); String cacheKey = AVATAR_CACHE_KEYS.get(avatarUrl); if (cacheKey == null) { cacheKey = avatarUrl; } if (HiSettingsHelper.getInstance().isCircleAvatar()) { glide.load(new AvatarModel(avatarUrl)) .signature(new ObjectKey(cacheKey)) .diskCacheStrategy(DiskCacheStrategy.NONE) .circleCrop() .error(DEFAULT_USER_ICON) .transition(DrawableTransitionOptions.withCrossFade()) .into(view); } else { glide.load(new AvatarModel(avatarUrl)) .signature(new ObjectKey(cacheKey)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new CenterCrop(), new RoundedCorners(Utils.dpToPx(4))) .error(DEFAULT_USER_ICON) .transition(DrawableTransitionOptions.withCrossFade()) .into(view); } }
Example #3
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public Target<Drawable> loadWithColorPlaceholderRoundCorners(String image, int radius, ImageView previewImage, @AttrRes int colorResource, RequestListener<Drawable> requestListener) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(image) .apply(getRequestOptions().centerCrop() .placeholder(new ColorDrawable(getAttrColor(colorResource))) .transforms(new CenterCrop(), new RoundedCorners(radius))) .listener(requestListener) .transition(DrawableTransitionOptions.withCrossFade()) .into(previewImage); } return null; }
Example #4
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #5
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); int size; if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { size = Defaults.IMAGE_HEIGHT; options.circleCrop(); } } else { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); } options.override(size, size); options.error(error_image); options.priority(Priority.HIGH); }
Example #6
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #7
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "deprecation" }) private void setupGlideOptions() { options = new RequestOptions(); int size; if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { size = Defaults.IMAGE_HEIGHT; options.circleCrop(); } } else { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); } options.override(size, size); options.error(error_image); options.priority(Priority.HIGH); }
Example #8
Source File: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) { SettableFuture<Boolean> future = new SettableFuture<>(); if (transferControls.isPresent()) getTransferControls().setVisibility(View.GONE); GlideRequest request = glideRequests.load(new DecryptableUri(uri)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transition(withCrossFade()); if (width > 0 && height > 0) { request = request.override(width, height); } if (radius > 0) { request = request.transforms(new CenterCrop(), new RoundedCorners(radius)); } else { request = request.transforms(new CenterCrop()); } request.into(new GlideDrawableListeningTarget(image, future)); blurhash.setImageDrawable(null); return future; }
Example #9
Source File: PickerLoader.java From VMLibrary with Apache License 2.0 | 5 votes |
/** * 通过上下文对象加载图片 * * @param context 上下文对象 * @param options 加载配置 * @param imageView 目标控件 */ @Override public void load(Context context, Options options, ImageView imageView) { RequestOptions requestOptions = new RequestOptions(); if (options.isCircle) { requestOptions.circleCrop(); } else if (options.isRadius) { requestOptions.transform(new MultiTransformation<>(new CenterCrop(), new RoundedCorners(options.radiusSize))); } GlideApp.with(context).load(options.url).apply(requestOptions).into(imageView); }
Example #10
Source File: GlideImageLoader.java From NIM_Android_UIKit with MIT License | 5 votes |
@Override public void displayImage(Context context, String path, ImageView imageView, int width, int height) { RequestOptions options = new RequestOptions() .placeholder(R.drawable.nim_placeholder_normal_impl) //设置占位图片 .error(R.drawable.nim_placeholder_normal_impl) //设置错误图片 .diskCacheStrategy(DiskCacheStrategy.ALL) .transforms(new CenterCrop(), new RoundedCorners(ScreenUtil.dip2px(4))) .override(width, height) .dontAnimate(); //缓存全尺寸 Glide.with(context) //配置上下文 .asDrawable() .apply(options) .load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示) .into(imageView); }
Example #11
Source File: ThumbnailView.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
private GlideRequest applySizing(@NonNull GlideRequest request, @NonNull BitmapTransformation fitting) { int[] size = new int[2]; fillTargetDimensions(size, dimens, bounds); if (size[WIDTH] == 0 && size[HEIGHT] == 0) { size[WIDTH] = getDefaultWidth(); size[HEIGHT] = getDefaultHeight(); } return request.override(size[WIDTH], size[HEIGHT]) .transforms(fitting, new RoundedCorners(radius)); }
Example #12
Source File: ThumbnailView.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri) { SettableFuture<Boolean> future = new SettableFuture<>(); glideRequests.load(new DecryptableUri(uri)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transforms(new CenterCrop(), new RoundedCorners(radius)) .transition(withCrossFade()) .into(new GlideDrawableListeningTarget(image, future)); return future; }
Example #13
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadWithRoundCorners(String image, int radius, ImageView previewImage, @AttrRes int placeHolderDrawableId, RequestListener<Drawable> requestListener) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(image) .apply(getRequestOptions().centerCrop() .placeholder(getAttrDrawable(placeHolderDrawableId)) .transforms(new CenterCrop(), new RoundedCorners(radius))) .listener(requestListener) .transition(DrawableTransitionOptions.withCrossFade()) .into(previewImage); } return null; }
Example #14
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public void loadWithRoundCorners(String image, int radius, ImageView previewImage, @AttrRes int placeHolderDrawableId) { Context context = weakContext.get(); if (context != null) { Glide.with(context) .load(image) .apply(getRequestOptions().centerCrop() .placeholder(getAttrDrawable(placeHolderDrawableId)) .transforms(new CenterInside(), new RoundedCorners(radius))) .transition(DrawableTransitionOptions.withCrossFade()) .into(previewImage); } }
Example #15
Source File: GlideLoader.java From XDroidMvp with MIT License | 5 votes |
@Override public void loadCorner(String url, final ImageView target, int radius, Options options) { RequestOptions requestOptions = wrapScaleType(options); //设置图片圆角角度 MultiTransformation multiTransformation = new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCorners(radius)); requestOptions.transform(multiTransformation); getRequestManager(target.getContext()) .load(url) .apply(requestOptions) .transition(withCrossFade()) .into(target); }
Example #16
Source File: NewsGlideModule.java From NewsApp with GNU General Public License v3.0 | 5 votes |
@NonNull @GlideOption public static RequestOptions roundedCornerImage(RequestOptions options, @NonNull Context context, int radius) { if (radius > 0) { int px = Math.round(radius * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT)); return options.transforms(new CenterCrop(), new RoundedCorners(px)); } return options.transforms(new CenterCrop()); }
Example #17
Source File: BindingAdapters.java From PopularMovies with MIT License | 5 votes |
/** * Movie details poster image */ @BindingAdapter({"imageUrl"}) public static void bindImage(ImageView imageView, String imagePath) { GlideApp.with(imageView.getContext()) .load(Constants.IMAGE_URL + imagePath) .placeholder(R.color.md_grey_200) .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners((int) UiUtils.dipToPixels(imageView.getContext(), 8)))) .into(imageView); }
Example #18
Source File: ProjectUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取圆角 RequestOptions * @return 圆角 {@link RequestOptions} */ public static RequestOptions getRoundOptions10() { // 获取默认 RequestOptions RequestOptions roundOptions = GlideUtils.defaultOptions(); // 设置圆角, 使用 RoundedCorners 图片不会闪烁 return roundOptions.transform(new RoundedCorners(ResourceUtils.getDimensionInt(R.dimen.un_radius_10))); }
Example #19
Source File: ProjectUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取圆角 RequestOptions * @return 圆角 {@link RequestOptions} */ public static RequestOptions getRoundOptions() { if (sRoundOptions == null) { // 获取默认 RequestOptions sRoundOptions = GlideUtils.defaultOptions(); // 设置圆角, 使用 RoundedCorners 图片不会闪烁 sRoundOptions.transform(new RoundedCorners(ResourceUtils.getDimensionInt(R.dimen.un_radius))); } return sRoundOptions; }
Example #20
Source File: FileSelectorAdapter.java From HaoReader with GNU General Public License v3.0 | 4 votes |
@Override public void onBindViewHolder(@NonNull FileViewHolder holder, int position, @NonNull List<Object> payloads) { if (!payloads.isEmpty()) { holder.mChecker.setChecked(false); } else { final RipeFile item = files.get(holder.getLayoutPosition()); holder.mTvName.setText(item.getName()); if (item.isDirectory()) { holder.mIcon.setImageResource(R.drawable.ic_folder_black_24dp); AppCompat.setTint(holder.mIcon, holder.mChecker.getResources().getColor(R.color.colorAccent)); holder.mIcon.setVisibility(View.VISIBLE); holder.mAdded.setVisibility(View.INVISIBLE); holder.mCover.setVisibility(View.INVISIBLE); holder.mTvTag.setVisibility(View.GONE); holder.mChecker.setVisibility(View.GONE); holder.mTvInfo.setText(String.format(Locale.getDefault(), "%d项 | %s", item.getChildCount(), item.getDate())); } else { holder.mTvTag.setVisibility(View.VISIBLE); holder.mChecker.setVisibility(View.VISIBLE); AppCompat.setTint(holder.mIcon, holder.mChecker.getResources().getColor(R.color.transparent)); if (isImage) { holder.mIcon.setVisibility(View.INVISIBLE); holder.mAdded.setVisibility(View.INVISIBLE); holder.mCover.setVisibility(View.VISIBLE); Glide.with(fragment.get()).load(item.getPath()) .apply(new RequestOptions().placeholder(placeholder) .transform(new CenterCrop(), new RoundedCorners(ScreenUtils.dpToPx(3)))) .transition(new DrawableTransitionOptions().crossFade()) .into(holder.mCover); } else if (checkBookAdded && isAdded(item.getFile())) { holder.mIcon.setVisibility(View.INVISIBLE); holder.mAdded.setVisibility(View.VISIBLE); holder.mCover.setVisibility(View.INVISIBLE); holder.mIcon.setImageResource(R.drawable.ic_book_added_black_24dp); holder.mChecker.setVisibility(View.GONE); } else { holder.mIcon.setVisibility(View.VISIBLE); holder.mAdded.setVisibility(View.INVISIBLE); holder.mCover.setVisibility(View.INVISIBLE); holder.mIcon.setImageResource(R.drawable.ic_file_black_24dp); AppCompat.setTint(holder.mIcon, holder.mChecker.getResources().getColor(R.color.colorTextSecondary)); } holder.mTvTag.setText(item.getSuffix()); holder.mTvInfo.setText(String.format(Locale.getDefault(), "%s | %s", item.getSize(), item.getDate())); } holder.mChecker.setChecked(item.isSelected()); holder.itemView.setOnClickListener(v -> { if (fileNotExists(item, holder.getLayoutPosition())) { return; } if (!item.isDirectory() && !holder.mChecker.isShown()) { return; } if (singleChoice) { int index; if (lastSelectedFile != null && (index = files.indexOf(lastSelectedFile)) >= 0) { if(index != holder.getLayoutPosition()) { lastSelectedFile.setSelected(false); notifyItemChanged(index, index); } } if (!item.isDirectory()) { item.setSelected(!item.isSelected()); holder.mChecker.setChecked(item.isSelected()); lastSelectedFile = item; } } else { if (!item.isDirectory()) { item.setSelected(!item.isSelected()); holder.mChecker.setChecked(item.isSelected()); } } if (itemClickListener != null) { itemClickListener.onItemClick(v, item); } }); if (isImage) { holder.mCover.setOnClickListener(v -> { if (fileNotExists(item, holder.getLayoutPosition())) { return; } if (fragment.get() instanceof FileSelectorContract.View) { ((FileSelectorContract.View) fragment.get()).showBigImage(holder.mCover, item.getPath()); } }); } } }
Example #21
Source File: CommonGlideImageLoaderStrategy.java From Hands-Chopping with Apache License 2.0 | 4 votes |
@Override public void loadImage(Context ctx, CommonImageConfigImpl config) { Preconditions.checkNotNull(ctx, "Context is required"); Preconditions.checkNotNull(config, "ImageConfigImpl is required"); if (TextUtils.isEmpty(config.getUrl())) throw new NullPointerException("Url is required"); Preconditions.checkNotNull(config.getImageView(), "ImageView is required"); GlideRequests requests; requests = GlideArms.with(ctx);//如果context是activity则自动使用Activity的生命周期 GlideRequest<Drawable> glideRequest = requests.load(config.getUrl()); // switch (config.getCacheStrategy()) {//缓存策略 case 0: glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL); break; case 1: glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE); break; case 2: glideRequest.diskCacheStrategy(DiskCacheStrategy.RESOURCE); break; case 3: glideRequest.diskCacheStrategy(DiskCacheStrategy.DATA); break; case 4: glideRequest.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC); break; default: glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL); break; } if (config.isCrossFade()) { glideRequest.transition(DrawableTransitionOptions.withCrossFade()); } if (config.isImageRadius()) { glideRequest.transform(new RoundedCorners(config.getImageRadius())); } if (config.isBlurImage()) { glideRequest.transform(new BlurTransformation(config.getBlurValue())); } if (config.getTransformation() != null) {//glide用它来改变图形的形状 glideRequest.transform(config.getTransformation()); } if (config.getPlaceHolderDrawble() != null) { glideRequest.placeholder(config.getPlaceHolderDrawble()); } if (config.getPlaceholder() != 0)//设置占位符 glideRequest.placeholder(config.getPlaceholder()); if (config.getErrorPic() != 0)//设置错误的图片 glideRequest.error(config.getErrorPic()); if (config.getFallback() != 0)//设置请求 url 为空图片 glideRequest.fallback(config.getFallback()); if (config.getResizeX() != 0 && config.getResizeY() != 0) { glideRequest.override(config.getResizeX(), config.getResizeY()); } if (config.isCropCenter()) { glideRequest.centerCrop(); } if (config.isCropCircle()) { glideRequest.circleCrop(); } if (config.decodeFormate() != null) { glideRequest.format(config.decodeFormate()); } if (config.isFitCenter()) { glideRequest.fitCenter(); } glideRequest .into(config.getImageView()); }
Example #22
Source File: GlideImageLoaderStrategy.java From MVPArms with Apache License 2.0 | 4 votes |
@Override public void loadImage(@Nullable Context ctx, @Nullable ImageConfigImpl config) { Preconditions.checkNotNull(ctx, "Context is required"); Preconditions.checkNotNull(config, "ImageConfigImpl is required"); Preconditions.checkNotNull(config.getImageView(), "ImageView is required"); GlideRequests requests; requests = GlideArms.with(ctx);//如果context是activity则自动使用Activity的生命周期 GlideRequest<Drawable> glideRequest = requests.load(config.getUrl()); switch (config.getCacheStrategy()) { //缓存策略 case CacheStrategy.NONE: glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE); break; case CacheStrategy.RESOURCE: glideRequest.diskCacheStrategy(DiskCacheStrategy.RESOURCE); break; case CacheStrategy.DATA: glideRequest.diskCacheStrategy(DiskCacheStrategy.DATA); break; case CacheStrategy.AUTOMATIC: glideRequest.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC); break; default: glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL); break; } if (config.isCrossFade()) { glideRequest.transition(DrawableTransitionOptions.withCrossFade()); } if (config.isCenterCrop()) { glideRequest.centerCrop(); } if (config.isCircle()) { glideRequest.circleCrop(); } if (config.isImageRadius()) { glideRequest.transform(new RoundedCorners(config.getImageRadius())); } if (config.isBlurImage()) { glideRequest.transform(new BlurTransformation(config.getBlurValue())); } if (config.getTransformation() != null) {//glide用它来改变图形的形状 glideRequest.transform(config.getTransformation()); } if (config.getPlaceholder() != 0)//设置占位符 { glideRequest.placeholder(config.getPlaceholder()); } if (config.getErrorPic() != 0)//设置错误的图片 { glideRequest.error(config.getErrorPic()); } if (config.getFallback() != 0)//设置请求 url 为空图片 { glideRequest.fallback(config.getFallback()); } glideRequest .into(config.getImageView()); }
Example #23
Source File: TestFragmentC.java From AndroidProject with Apache License 2.0 | 4 votes |
@SingleClick @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_test_image1: mImageView.setVisibility(View.VISIBLE); GlideApp.with(this) .load("https://www.baidu.com/img/bd_logo.png") .into(mImageView); break; case R.id.btn_test_image2: mImageView.setVisibility(View.VISIBLE); GlideApp.with(this) .load("https://www.baidu.com/img/bd_logo.png") .circleCrop() .into(mImageView); break; case R.id.btn_test_image3: mImageView.setVisibility(View.VISIBLE); GlideApp.with(this) .load("https://www.baidu.com/img/bd_logo.png") .transform(new RoundedCorners((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, this.getResources().getDisplayMetrics()))) .into(mImageView); break; case R.id.btn_test_image4: PhotoActivity.start(getAttachActivity(), new PhotoActivity.OnPhotoSelectListener() { @Override public void onSelected(List<String> data) { mImageView.setVisibility(View.VISIBLE); GlideApp.with(getAttachActivity()) .load(data.get(0)) .into(mImageView); } @Override public void onCancel() { toast("取消了"); } }); break; case R.id.btn_test_toast: toast("我是吐司"); break; case R.id.btn_test_permission: XXPermissions.with(getAttachActivity()) // 可设置被拒绝后继续申请,直到用户授权或者永久拒绝 //.constantRequest() // 支持请求6.0悬浮窗权限8.0请求安装权限 //.permission(Permission.SYSTEM_ALERT_WINDOW, Permission.REQUEST_INSTALL_PACKAGES) // 不指定权限则自动获取清单中的危险权限 .permission(Permission.CAMERA) .request(new OnPermission() { @Override public void hasPermission(List<String> granted, boolean isAll) { if (isAll) { toast("获取权限成功"); } else { toast("获取权限成功,部分权限未正常授予"); } } @Override public void noPermission(List<String> denied, boolean quick) { if(quick) { toast("被永久拒绝授权,请手动授予权限"); //如果是被永久拒绝就跳转到应用权限系统设置页面 XXPermissions.gotoPermissionSettings(getAttachActivity()); } else { toast("获取权限失败"); } } }); break; case R.id.btn_test_setting: XXPermissions.gotoPermissionSettings(getAttachActivity()); break; case R.id.btn_test_state_black: if (getAttachActivity().getStatusBarConfig() != null) { getAttachActivity().getStatusBarConfig().statusBarDarkFont(true).init(); } break; case R.id.btn_test_state_white: if (getAttachActivity().getStatusBarConfig() != null) { getAttachActivity().getStatusBarConfig().statusBarDarkFont(false).init(); } break; default: break; } }
Example #24
Source File: GlideImageLoader.java From NIM_Android_UIKit with MIT License | 4 votes |
private static Transformation<Bitmap> createRounded(int dp) { return new RoundedCorners(ScreenUtil.dip2px(dp)); }
Example #25
Source File: CommonGlideImageLoaderStrategy.java From lifecycle-component with Apache License 2.0 | 4 votes |
@Override public void loadImage(Context ctx, CommonImageConfigImpl config) { Preconditions.checkNotNull(ctx, "Context is required"); Preconditions.checkNotNull(config, "ImageConfigImpl is required"); if (TextUtils.isEmpty(config.getUrl())) throw new NullPointerException("Url is required"); Preconditions.checkNotNull(config.getImageView(), "ImageView is required"); GlideRequests requests; requests = GlideArms.with(ctx);//如果context是activity则自动使用Activity的生命周期 GlideRequest<Drawable> glideRequest = requests.load(config.getUrl()); // switch (config.getCacheStrategy()) {//缓存策略 case 0: glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL); break; case 1: glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE); break; case 2: glideRequest.diskCacheStrategy(DiskCacheStrategy.RESOURCE); break; case 3: glideRequest.diskCacheStrategy(DiskCacheStrategy.DATA); break; case 4: glideRequest.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC); break; default: glideRequest.diskCacheStrategy(DiskCacheStrategy.ALL); break; } if (config.isCrossFade()) { glideRequest.transition(DrawableTransitionOptions.withCrossFade()); } if (config.isImageRadius()) { glideRequest.transform(new RoundedCorners(config.getImageRadius())); } if (config.isBlurImage()) { glideRequest.transform(new BlurTransformation(config.getBlurValue())); } if (config.getTransformation() != null) {//glide用它来改变图形的形状 glideRequest.transform(config.getTransformation()); } if (config.getPlaceHolderDrawble() != null) { glideRequest.placeholder(config.getPlaceHolderDrawble()); } if (config.getPlaceholder() != 0)//设置占位符 glideRequest.placeholder(config.getPlaceholder()); if (config.getErrorPic() != 0)//设置错误的图片 glideRequest.error(config.getErrorPic()); if (config.getFallback() != 0)//设置请求 url 为空图片 glideRequest.fallback(config.getFallback()); if (config.getResizeX() != 0 && config.getResizeY() != 0) { glideRequest.override(config.getResizeX(), config.getResizeY()); } if (config.isCropCenter()) { glideRequest.centerCrop(); } if (config.isCropCircle()) { glideRequest.circleCrop(); } if (config.decodeFormate() != null) { glideRequest.format(config.decodeFormate()); } if (config.isFitCenter()) { glideRequest.fitCenter(); } glideRequest .into(config.getImageView()); }
Example #26
Source File: ImageUtils.java From edx-app-android with Apache License 2.0 | 4 votes |
public static void setRoundedCornerImage(@NonNull ImageView imageView, @DrawableRes int drawableRes) { final Context context = imageView.getContext(); final int cornerRadius = context.getResources().getDimensionPixelSize(R.dimen.subject_item_corner_radius); Glide.with(context).load(drawableRes).transform(new RoundedCorners(cornerRadius)).into(imageView); }
Example #27
Source File: GlideManager.java From TitleBarView with Apache License 2.0 | 3 votes |
/** * 加载圆角图片 * * @param obj 加载的图片资源 * @param iv * @param dp 圆角尺寸-dp * @param placeholderResource -占位图 * @param isOfficial-是否官方模式圆角 */ public static void loadRoundImg(Object obj, ImageView iv, float dp, int placeholderResource, boolean isOfficial) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholderResource) .placeholder(placeholderResource) .fallback(placeholderResource) .dontAnimate() .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(iv.getContext(), dp2px(dp)))).into(iv); }
Example #28
Source File: GlideManager.java From UIWidget with Apache License 2.0 | 3 votes |
/** * 加载圆角图片 * * @param obj 加载的图片资源 * @param iv * @param dp 圆角尺寸-dp * @param placeholderResource -占位图 * @param isOfficial-是否官方模式圆角 */ public static void loadRoundImg(Object obj, ImageView iv, float dp, int placeholderResource, boolean isOfficial) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholderResource) .placeholder(placeholderResource) .fallback(placeholderResource) .dontAnimate() .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(iv.getContext(), dp2px(dp)))).into(iv); }
Example #29
Source File: GlideManager.java From FastLib with Apache License 2.0 | 3 votes |
/** * 加载圆角图片 * * @param obj 加载的图片资源 * @param iv * @param dp 圆角尺寸-dp * @param placeholder -占位图 * @param isOfficial-是否官方模式圆角 */ public static void loadRoundImg(Object obj, ImageView iv, float dp, Drawable placeholder, boolean isOfficial) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholder) .placeholder(placeholder) .fallback(placeholder) .dontAnimate() .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(dp2px(dp)))).into(iv); }