Here I facing a problem with the puzzle game, I have an Image make in to some square tiles, I shuffled and rotated the bitmap tile in to 90 180 or 270 degrees, and set those to the adapter in a gridview. Now I applied onTouch listener on the grid view items, I can drag and drop the tiles on the gridview, but the problem is when I touch and drag the 90 or 180 or 270 degrees tile showing original tile, like, a tile with 0 degrees. Below is my code please review that and provide me suggestions.
public boolean onTouch(View v, MotionEvent event) {
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (hashMap.containsKey(v)) {
touchedItemPosition = hashMap.get(v);
touchedItemPos = touchedItemPosition;
MyBitamp bitamp = itemList_dump.get(touchedItemPos);
v.startDrag(data, shadowBuilder, v, 0);
}
v.setVisibility(View.INVISIBLE);
return true;
} else
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
v.setVisibility(View.VISIBLE);
return false;
}
else
if (event.getAction() == MotionEvent.ACTION_MOVE) {
return true;
}
else if (event.getAction() == MotionEvent.ACTION_UP) {
}
return false;
}
public boolean onDrag(View v, DragEvent event) {
dropedItemPosition = hashMap.get(v);
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
break;
case DragEvent.ACTION_DRAG_EXITED:
break;
case DragEvent.ACTION_DROP:
swapItemPositions(dropedItemPosition, touchedItemPosition);
break;
case DragEvent.ACTION_DRAG_ENDED:
Log.i("Drop", "end");
default:
break;
}
return true;
}