高斯模糊处理
//存放圖片的字段是否為空
if (!TextUtils.isEmpty(personInfoBean.avatar)) {//調用Picasso圖片緩存庫Picasso.with(getContext()).load(personInfoBean.avatar + ImagSizeMode.imageSizeBeens[3].size).into(civPhoto, new Callback() {@Override
//圖片下載成功civPhotopublic void onSuccess() {blur(true);}//圖下載失敗@Overridepublic 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() {@Overridepublic 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);}});}
if (!TextUtils.isEmpty(personInfoBean.avatar)) {//調用Picasso圖片緩存庫Picasso.with(getContext()).load(personInfoBean.avatar + ImagSizeMode.imageSizeBeens[3].size).into(civPhoto, new Callback() {@Override
//圖片下載成功civPhotopublic void onSuccess() {blur(true);}//圖下載失敗@Overridepublic 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() {@Overridepublic 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);}});}
?
轉載于:https://www.cnblogs.com/rookie-26/p/5713587.html
總結
- 上一篇: Python中的strip()函数的用法
- 下一篇: 怎样使用My97日期控件