Create a gist now

Instantly share code, notes, and snippets.

@hkosacki /onDrag.java Secret
Created Mar 1, 2017

Embed
What would you like to do?
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
Log.d("dragEvent", dragEvent.toString());
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_ENDED:
Log.d("event", "ACTION_DRAG_ENDED");
dragLayout.setVisibility(View.GONE);
dragLayout.setBackgroundResource(R.drawable.drag_background);
return true;
case DragEvent.ACTION_DRAG_ENTERED:
Log.d("event", "ACTION_DRAG_ENTERED");
dragLayout.setBackgroundResource(R.drawable.drag_background_active);
return true;
case DragEvent.ACTION_DRAG_EXITED:
Log.d("event", "ACTION_DRAG_EXITED");
dragLayout.setBackgroundResource(R.drawable.drag_background);
return true;
case DragEvent.ACTION_DRAG_LOCATION:
Log.d("event", "ACTION_DRAG_LOCATION");
return true;
case DragEvent.ACTION_DRAG_STARTED:
Log.d("event", "ACTION_DRAG_STARTED");
dragLayout.setVisibility(View.VISIBLE);
return true;
case DragEvent.ACTION_DROP:
Log.d("event", "ACTION_DRAG_DROP");
handleDropEvent(view, dragEvent);
return true;
default:
Log.e("event", "unknown");
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment