Make sure that there is nothing referring to the bitmap before recycling it.
Hopefully this will fix bug 2157769.
diff --git a/src/com/android/music/TouchInterceptor.java b/src/com/android/music/TouchInterceptor.java
index 8476011..6c22e72 100644
--- a/src/com/android/music/TouchInterceptor.java
+++ b/src/com/android/music/TouchInterceptor.java
@@ -37,7 +37,7 @@
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 @@
}
private void startDragging(Bitmap bm, int y) {
+ stopDragging();
+
mWindowParams = new WindowManager.LayoutParams();
mWindowParams.gravity = Gravity.TOP;
mWindowParams.x = 0;
@@ -337,10 +339,6 @@
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 @@
}
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;