List of usage examples for android.view DragEvent getY
public float getY()
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
@Override public boolean dispatchDragEvent(DragEvent event) { if (!isDragReorderingSupported()) { // If the consumer of this StaggeredGridView has not registered a ReorderListener, // don't bother handling drag events. return super.dispatchDragEvent(event); }//w ww .j ava 2 s .c o m switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: // Per bug 7071594, we won't be able to catch this event in onDragEvent, // so we'll handle the event as it is being dispatched on the way down. if (mReorderHelper.hasReorderListener() && mIsDragReorderingEnabled) { final View child = getChildAtCoordinate(mTouchDownForDragStartX, mTouchDownForDragStartY); if (child != null) { // Child can be null if the touch point is not on a child view, but is // still within the bounds of this StaggeredGridView (i.e., margins // between cells). startDragging(child, mTouchDownForDragStartX, mTouchDownForDragStartY); // We must return true in order to continue getting future // {@link DragEvent}s. return true; } } // Be sure to return a value here instead of calling super.dispatchDragEvent() // which will unnecessarily dispatch to all the children (since the // {@link StaggeredGridView} handles all drag events for our purposes) return false; case DragEvent.ACTION_DROP: case DragEvent.ACTION_DRAG_ENDED: if (mDragState == ReorderUtils.DRAG_STATE_DRAGGING) { handleDrop((int) event.getX(), (int) event.getY()); } // Return early here to avoid calling super.dispatchDragEvent() which dispatches to // children (since this view already can handle all drag events). The super call // can also cause a NPE if the view hierarchy changed in the middle of a drag // and the {@link DragEvent} gets nulled out. This is a workaround for // a framework bug: 8298439. // Since the {@link StaggeredGridView} handles all drag events for our purposes, // just manually fire the drag event to ourselves. return onDragEvent(event); } // In all other cases, default to the superclass implementation. We need this so that // the drag/drop framework will fire off {@link #onDragEvent(DragEvent ev)} calls to us. return super.dispatchDragEvent(event); }