Java Code Examples for android.view.View.OnDragListener

The following are Jave code examples for showing how to use OnDragListener of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Blockly   File: TrashCanView.java   Source Code and License Vote up 6 votes
@Override
public void setOnDragListener(final View.OnDragListener dragListener) {
    View.OnDragListener wrapper = new OnDragListener() {
        @Override
        public boolean onDrag(View view, DragEvent dragEvent) {
            int action = dragEvent.getAction();
            // Whether the dragged object can be handled by the trash.
            boolean result = dragListener.onDrag(view, dragEvent);
            if (action == DragEvent.ACTION_DRAG_ENDED) {
                setState(STATE_DEFAULT);
            } else  if (result) {
                switch (action) {
                    case DragEvent.ACTION_DRAG_ENTERED:
                        setState(STATE_ON_HOVER);
                        break;
                    case DragEvent.ACTION_DROP:
                    case DragEvent.ACTION_DRAG_EXITED:
                        setState(STATE_DEFAULT);
                        break;
                }
            }
            return result;
        }
    };
    super.setOnDragListener(wrapper);
}
 
Example 2
Project: LaunchTime   File: QuickRow.java   Source Code and License Vote up 6 votes
public QuickRow(final View.OnDragListener dragListener, MainActivity mainActivity) {

        mMainActivity = mainActivity;

        mQuickRow = mMainActivity.findViewById(R.id.layout_quickrow);

        mQuickRowScroller = mMainActivity.findViewById(R.id.layout_quickrow_scroll);

        mQuickRow.setOnDragListener(dragListener);
        mQuickRowScroller.setOnDragListener(new View.OnDragListener() {
            @Override
            public boolean onDrag(View view, DragEvent dragEvent) {
                return dragListener.onDrag(mQuickRow, dragEvent);
            }
        });
    }
 
Example 3
Project: Blockly   File: Dragger.java   Source Code and License Vote up 4 votes
/**
 * @return The listener to use for {@link DragEvent}'s in the {@link WorkspaceView}.
 */
public View.OnDragListener getDragEventListener() {
    return mDragEventListener;
}
 
Example 4
Project: egma-shapi   File: DragListener.java   Source Code and License Vote up 4 votes
private void initiliazeInternalListener() {
    mInternalDragListener = new View.OnDragListener() {

        @Override
        public boolean onDrag(View v, DragEvent event) {

            switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_STARTED:

                    // check if listener could catch this event.
                    ClipDescription description = event.getClipDescription();
                    if (description == null) {
                        return false;
                    }
                    String className = String.valueOf(description.getLabel());
                    if (mDraggedItem == null && mHandledClassNames.contains(className)) {

                        // retrieve the data object linked to the dragged event.
                        mDraggedItem = DragHelper.getDraggedItem(((Integer) event.getLocalState()));
                        onDragStarted(mDraggedItem.getSource(), mDraggedItem.getData());

                        return true;
                    } else {
                        return false;
                    }
                case DragEvent.ACTION_DRAG_ENTERED:
                    onDragEntered(mDraggedItem.getSource(), mDraggedItem.getData());
                    break;
                case DragEvent.ACTION_DRAG_LOCATION:
                    onDragLocation(
                            mDraggedItem.getSource(), mDraggedItem.getData(),
                            event.getX(), event.getY()
                    );
                    break;
                case DragEvent.ACTION_DROP:
                    onDragDropped(
                            mDraggedItem.getSource(), mDraggedItem.getData(),
                            event.getX(), event.getY()
                    );
                    break;
                case DragEvent.ACTION_DRAG_EXITED:
                    onDragExited(mDraggedItem.getSource(), mDraggedItem.getData());
                    break;
                case DragEvent.ACTION_DRAG_ENDED:
                    if (mDraggedItem != null) {
                        onDragEnded(mDraggedItem.getSource(), mDraggedItem.getData());
                        DragHelper.clearDraggedItem(mDraggedItem.getToken());
                        mDraggedItem = null;
                    }
                    break;
                default:
                    break;
            }
            return true;
        }
    };
}
 
Example 5
Project: egma-shapi   File: DragListener.java   Source Code and License Vote up 2 votes
/**
 * Retrieve the internal drag listener.
 *
 * @return internal drag listener.
 */
View.OnDragListener getInternalDragListener() {
    return mInternalDragListener;
}
 
Example 6
Project: leoapp-sources   File: InfoButton.java   Source Code and License Vote up 2 votes
/**
 * Delegiert von android.widget.Button
 *
 * @param l siehe {@link Button}
 */
public void setOnDragListener(View.OnDragListener l) {
    b.setOnDragListener(l);
}