Skip to content

Commit

Permalink
glide 加载图形图片 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XinYiWorld committed May 4, 2017
1 parent daf36c8 commit 4571981
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.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 @@ -4,13 +4,17 @@
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.xinyi.czbasedevtool.base.R;

/**
* 图片加载Main类
* author:Created by ChenZhang on 2016/6/24 0024.
* function:
* 1)Glide加载圆形图片第一次只显示默认图片:http://blog.csdn.net/qq_26413249/article/details/52217322
*/
public class GlideMaster {
private static int placeHolderRes = R.mipmap.ic_launcher;
Expand All @@ -22,20 +26,32 @@ public static void init(int placeHolderRes2,int errorHolderRes2){
}


public static void display(Context mContext,String url, ImageView img){
public static void display(Context mContext, String url, final ImageView img){
Glide.with(mContext)
.load(url)
.placeholder(placeHolderRes)
.error(errorHolderRes)
.into(img);
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource,
GlideAnimation<? super GlideDrawable> glideAnimation) {
img.setImageDrawable(resource);
}
});
}

public static void display(Context mContext, String url, ImageView img, RequestListener listener){
public static void display(Context mContext, String url, final ImageView img, RequestListener listener){
Glide.with(mContext)
.load(url)
.listener(listener)
.placeholder(placeHolderRes)
.error(errorHolderRes)
.into(img);
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource,
GlideAnimation<? super GlideDrawable> glideAnimation) {
img.setImageDrawable(resource);
}
});
}
}

0 comments on commit 4571981

Please sign in to comment.