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
}
private void startDragging(Bitmap bm, int y) {
+ stopDragging();
+
mWindowParams = new WindowManager.LayoutParams();
mWindowParams.gravity = Gravity.TOP;
mWindowParams.x = 0;
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");
}
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;