com.jess.arms.http.imageloader.glide.GlideArms Java Examples
The following examples show how to use
com.jess.arms.http.imageloader.glide.GlideArms.
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: 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 #2
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 #3
Source File: GlideEngine.java From Aurora with Apache License 2.0 | 4 votes |
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { GlideArms.with(context).asBitmap().load(uri).placeholder(placeholder).override(resize, resize).centerCrop().into(imageView); }
Example #4
Source File: GlideEngine.java From Aurora with Apache License 2.0 | 4 votes |
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { GlideArms.with(context).asBitmap().load(uri).placeholder(placeholder).override(resize, resize).centerCrop().into(imageView); }
Example #5
Source File: GlideEngine.java From Aurora with Apache License 2.0 | 4 votes |
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { GlideArms.with(context).asBitmap().load(uri).override(resizeX, resizeY).priority(Priority.HIGH).into(imageView); }
Example #6
Source File: GlideEngine.java From Aurora with Apache License 2.0 | 4 votes |
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { GlideArms.with(context).asBitmap().load(uri).override(resizeX, resizeY).priority(Priority.HIGH).into(imageView); }