OSDN Git Service

Make sure that there is nothing referring to the bitmap before recycling it.
authorMarco Nelissen <marcone@google.com>
Thu, 1 Oct 2009 17:15:41 +0000 (10:15 -0700)
committerMarco Nelissen <marcone@google.com>
Thu, 1 Oct 2009 17:15:41 +0000 (10:15 -0700)
Hopefully this will fix bug 2157769.

src/com/android/music/TouchInterceptor.java

index 8476011..6c22e72 100644 (file)
@@ -37,7 +37,7 @@ import android.widget.ListView;
 
 public class TouchInterceptor extends ListView {
     
-    private View mDragView;
+    private ImageView mDragView;
     private WindowManager mWindowManager;
     private WindowManager.LayoutParams mWindowParams;
     private int mDragPos;      // which item is being dragged
@@ -319,6 +319,8 @@ public class TouchInterceptor extends ListView {
     }
     
     private void startDragging(Bitmap bm, int y) {
+        stopDragging();
+
         mWindowParams = new WindowManager.LayoutParams();
         mWindowParams.gravity = Gravity.TOP;
         mWindowParams.x = 0;
@@ -337,10 +339,6 @@ public class TouchInterceptor extends ListView {
         int backGroundColor = mContext.getResources().getColor(R.color.dragndrop_background);
         v.setBackgroundColor(backGroundColor);
         v.setImageBitmap(bm);
-
-        if (mDragBitmap != null) {
-            mDragBitmap.recycle();
-        }
         mDragBitmap = bm;
 
         mWindowManager = (WindowManager)mContext.getSystemService("window");
@@ -362,9 +360,12 @@ public class TouchInterceptor extends ListView {
     }
     
     private void stopDragging() {
-        WindowManager wm = (WindowManager)mContext.getSystemService("window");
-        wm.removeView(mDragView);
-        mDragView = null;
+        if (mDragView != null) {
+            WindowManager wm = (WindowManager)mContext.getSystemService("window");
+            wm.removeView(mDragView);
+            mDragView.setImageDrawable(null);
+            mDragView = null;
+        }
         if (mDragBitmap != null) {
             mDragBitmap.recycle();
             mDragBitmap = null;