Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ILoader类中Option类加入了BitmapTransformation #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/dictionaries/HitomiT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
}

}