0
点赞
收藏
分享

微信扫一扫

grid点击

Soy丶sauce 2023-04-18 阅读 56


/**
 
     * Recycle bitmap resources
     
 */
 
    
 public 
 void recycleBitmapRes() {
 
        
 if (mConvertViews != 
 null && !mConvertViews.isEmpty()) {
 
            Collection<View> views = mConvertViews.values();
 
            mConvertViews.clear();
 
            
 for (View view : views) {
 
                ImageView icon = (ImageView) view.findViewById(R.id.imgIcon);
 
                
 if (icon != 
 null) {
 
                    
 if (icon.getDrawable() != 
 null && icon.getDrawable() 
 instanceof BitmapDrawable) {
 
                        Bitmap bitmap = ((BitmapDrawable) icon.getDrawable()).getBitmap();
 
                        
 if (bitmap != 
 null && !bitmap.isRecycled()) {
 
                            bitmap.recycle();
 
                        }
 
                    }
 
                }
 
            }
 
        }
 
    }
 

     @Override
 
    
 public 
 void notifyDataSetChanged(){
 
        
 //
 Avoiding that buttons cannot be pressed
 
        Utils.LogI("GameListAdapter", "notifyDataSetChanged");
 
        recycleBitmapRes();
 
        
 super.notifyDataSetChanged();
 
    }

举报

相关推荐

0 条评论