Java Code Examples for com.bumptech.glide.request.RequestOptions#fitCenter()
The following examples show how to use
com.bumptech.glide.request.RequestOptions#fitCenter() .
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: AvatarCropFragment.java From bcm-android with GNU General Public License v3.0 | 5 votes |
private void onPresentImage(ImageView imageView, String imageUri, int size) { RequestOptions options = new RequestOptions(); options.fitCenter(); options.override(Target.SIZE_ORIGINAL); Glide.with(imageView.getContext()) .load(new File(imageUri)) .apply(options) .into(imageView); }
Example 2
Source File: GlideLoader.java From XDroidMvp with MIT License | 5 votes |
private RequestOptions wrapScaleType(Options options) { RequestOptions request = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .priority(Priority.HIGH); if (options != null){ if (options.scaleType != null) { if (options.loadingResId != Options.RES_NONE) { request.placeholder(options.loadingResId); } if (options.loadErrorResId != Options.RES_NONE) { request.error(options.loadErrorResId); } switch (options.scaleType) { case MATRIX: case FIT_XY: case FIT_START: case FIT_END: case CENTER: case CENTER_INSIDE: break; case FIT_CENTER: request.fitCenter(); break; case CENTER_CROP: request.centerCrop(); break; } } else { request.centerCrop(); } }else { request.centerCrop(); } return request; }
Example 3
Source File: GlideImageLoaderStrategy.java From NewFastFrame with Apache License 2.0 | 4 votes |
@Override public void loadImage(Context context, GlideImageLoaderConfig config) { if (config == null || context == null) { return; } RequestBuilder drawableRequestBuilder; if (config.asGif()) { drawableRequestBuilder = Glide.with(context).asGif().load(config.getUrl()); } else { drawableRequestBuilder = Glide.with(context).load(config.getUrl()); } RequestOptions options = new RequestOptions(); switch (config.getCacheStrategy()) { case GlideImageLoaderConfig.CACHE_ALL: options.diskCacheStrategy(DiskCacheStrategy.ALL); break; case GlideImageLoaderConfig.CACHE_NONE: options.diskCacheStrategy(DiskCacheStrategy.NONE); break; case GlideImageLoaderConfig.CACHE_SOURCE: options.diskCacheStrategy(DiskCacheStrategy.RESOURCE); break; case GlideImageLoaderConfig.CACHE_RESULT: options.diskCacheStrategy(DiskCacheStrategy.DATA); break; default: break; } if (config.isCenterInside()) { options = options.fitCenter(); } else { options = options.centerCrop(); } if (config.getBitmapTransformation() != null) { options = options.transforms(config.getBitmapTransformation()); } if (config.getErrorResId() != 0) { options = options.error(config.getErrorResId()); } if (config.getPlaceHolderResId() != 0) { options = options.placeholder(config.getPlaceHolderResId()); } if (config.getWidth() != 0 && config.getHeight() != 0) { options = options.override(config.getWidth(), config.getHeight()); } if (config.getView() instanceof ImageView) { drawableRequestBuilder.apply(options).into((ImageView) config.getView()); } else { drawableRequestBuilder.apply(options).into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { if (config.getView()!=null) { config.getView().setBackground(resource); } } }); } }