//存放图片的字段是否为空
if (!TextUtils.isEmpty(personInfoBean.avatar)) {
//调用Picasso图片缓存库
Picasso.with(getContext()).load(personInfoBean.avatar + ImagSizeMode.imageSizeBeens[3].size).into(civPhoto, new Callback() {
@Override
//图片下载成功civPhoto
public void onSuccess() {
blur(true);
}
//图下载失败
@Override
public void onError() {
blur(false);
}
});
} else {
blur(false);
}
/**
* 高斯模糊处理
*/
private void blur(boolean hasChanged) {
//civPhoto没有更新,获取civPhot原来图片
if (hasChanged) {
rightTop.setImageDrawable(civPhoto.getDrawable());
}
//高斯模糊
rightTop.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
rightTop.getViewTreeObserver().removeOnGlobalLayoutListener(this);
Blurry.with(getContext())
.radius(10)
.sampling(1)
.color(Color.argb(0, 0, 0, 0))
.async()
.capture(rightTop)
.into(rightTop);
}
});
}