From 36e126ac145d0e6970e331fa85cf08f2877a430c Mon Sep 17 00:00:00 2001 From: HitomiT Date: Sun, 12 Feb 2017 21:20:42 +0800 Subject: [PATCH] =?UTF-8?q?add=20ILoader=E7=B1=BB=E4=B8=ADOption=E7=B1=BB?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E4=BA=86BitmapTransformation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dictionaries/HitomiT.xml | 3 +++ .../cn/droidlover/xdroidmvp/imageloader/GlideLoader.java | 9 ++++++++- .../cn/droidlover/xdroidmvp/imageloader/ILoader.java | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .idea/dictionaries/HitomiT.xml diff --git a/.idea/dictionaries/HitomiT.xml b/.idea/dictionaries/HitomiT.xml new file mode 100644 index 0000000..9d9c93f --- /dev/null +++ b/.idea/dictionaries/HitomiT.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/GlideLoader.java b/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/GlideLoader.java index 5864f1b..0c979a9 100644 --- a/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/GlideLoader.java +++ b/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/GlideLoader.java @@ -120,12 +120,19 @@ private void load(DrawableTypeRequest request, ImageView target, Options options request.error(options.loadErrorResId); } - wrapScaleType(request, options) + wrapTransformation(wrapScaleType(request, options), options) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .crossFade() .into(target); } + private DrawableTypeRequest wrapTransformation(DrawableTypeRequest request, Options options) { + if (options.transformation != null) { + request.bitmapTransform(options.transformation); + } + return request; + } + private DrawableTypeRequest wrapScaleType(DrawableTypeRequest request, Options options) { if (options != null && options.scaleType != null) { diff --git a/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/ILoader.java b/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/ILoader.java index 7002e4e..5acf218 100644 --- a/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/ILoader.java +++ b/mvp/src/main/java/cn/droidlover/xdroidmvp/imageloader/ILoader.java @@ -3,6 +3,8 @@ import android.content.Context; import android.widget.ImageView; +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; + import java.io.File; import cn.droidlover.xdroidmvp.XDroidConf; @@ -39,6 +41,7 @@ class Options { public int loadingResId = RES_NONE; //加载中的资源id public int loadErrorResId = RES_NONE; //加载失败的资源id public ImageView.ScaleType scaleType = null; + public BitmapTransformation transformation = null; public static final int RES_NONE = -1; @@ -55,6 +58,11 @@ public Options scaleType(ImageView.ScaleType scaleType) { this.scaleType = scaleType; return this; } + + public Options transform(BitmapTransformation transformation) { + this.transformation = transformation; + return this; + } } }