/** Drag and drop */ @Override public boolean onDragEvent(DragEvent event) { boolean result = false; switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: { // cache whether we accept the drag to return for LOCATION events mDragInProgress = true; mAcceptsDrag = result = true; // Redraw in the new visual state if we are a potential drop target if (this == Constants.currentBlank) { invalidate(); } } break; case DragEvent.ACTION_DRAG_ENDED: { if (Constants.droppedOnBlank) { if (this == Constants.currentDragged) { invalidate(); this.setOnLongClickListener(null); this.setTile( new Tile( this.tile.posOnBoard, "tile_blank", Constants.currentBlank.tile.id, MoveDirection.NONE, Constants.BLANK, Constants.Blank_Bmp)); Constants.currentBlank = this; System.out.println("set new blank****"); Constants.currentDragged = null; } else { invalidate(); } game.handleDragEnded(); } else { invalidate(); } mDragInProgress = false; mHovering = false; } break; case DragEvent.ACTION_DRAG_LOCATION: { // we returned true to DRAG_STARTED, so return true here result = mAcceptsDrag; } break; case DragEvent.ACTION_DROP: { processDrop(event); result = true; } break; case DragEvent.ACTION_DRAG_ENTERED: { mHovering = true; invalidate(); } break; case DragEvent.ACTION_DRAG_EXITED: { mHovering = false; invalidate(); } break; default: result = mAcceptsDrag; break; } return result; }