Java 类android.view.DragEvent 实例源码

项目:LaunchEnr    文件:PinItemDragListener.java   
@Override
public boolean onDrag(View view, DragEvent event) {
    if (mLauncher == null || mDragController == null) {
        postCleanup();
        return false;
    }
    if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) {
        if (onDragStart(event)) {
            return true;
        } else {
            postCleanup();
            return false;
        }
    }
    return mDragController.onDragEvent(mDragStartTime, event);
}
项目:LaunchEnr    文件:FlingToDeleteHelper.java   
/**
 * Same as {@link #recordMotionEvent}. It creates a temporary {@link MotionEvent} object
 * using {@param event} for tracking velocity.
 */
void recordDragEvent(long dragStartTime, DragEvent event) {
    final int motionAction;
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            motionAction = MotionEvent.ACTION_DOWN;
            break;
        case DragEvent.ACTION_DRAG_LOCATION:
            motionAction = MotionEvent.ACTION_MOVE;
            break;
        case DragEvent.ACTION_DRAG_ENDED:
            motionAction = MotionEvent.ACTION_UP;
            break;
        default:
            return;
    }
    MotionEvent emulatedEvent = MotionEvent.obtain(dragStartTime, SystemClock.uptimeMillis(),
            motionAction, event.getX(), event.getY(), 0);
    recordMotionEvent(emulatedEvent);
    emulatedEvent.recycle();
}
项目:chromium-for-android-56-debug-video    文件:CompositorViewHolder.java   
@Override
public boolean dispatchDragEvent(DragEvent e) {
    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null) return false;

    if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
    contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    boolean ret = super.dispatchDragEvent(e);

    int action = e.getAction();
    if (action == DragEvent.ACTION_DRAG_EXITED || action == DragEvent.ACTION_DRAG_ENDED
            || action == DragEvent.ACTION_DROP) {
        contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
    }
    return ret;
}
项目:Blockly    文件:Dragger.java   
/**
 * Continue dragging the currently moving block.  Called during ACTION_DRAG_LOCATION.
 *
 * @param event The next drag event to handle, as received by the {@link WorkspaceView}.
 */
private void continueDragging(DragEvent event) {
    updateBlockPosition(event);

    // highlight as we go
    BlockView highlightedBlockView = mHighlightedBlockViewRef.get();
    if (highlightedBlockView != null) {
        highlightedBlockView.setHighlightedConnection(null);
    }
    Pair<Connection, Connection> connectionCandidate =
            findBestConnection(mPendingDrag.getRootDraggedBlock());
    if (connectionCandidate != null) {
        highlightedBlockView = mViewHelper.getView(connectionCandidate.second.getBlock());
        mHighlightedBlockViewRef = new WeakReference<>(highlightedBlockView);
        highlightedBlockView.setHighlightedConnection(connectionCandidate.second);
    }

    mPendingDrag.getDragGroup().requestLayout();
}
项目:Blockly    文件:Dragger.java   
/**
 * Move the currently dragged block in response to a new {@link MotionEvent}.
 * <p/>
 * All of the child blocks move with the root block based on its position during layout.
 *
 * @param event The {@link MotionEvent} to react to.
 */
private void updateBlockPosition(DragEvent event) {
    // The event is relative to the WorkspaceView. Grab the pixel offset within.
    ViewPoint curDragLocationPixels = mTempViewPoint;
    curDragLocationPixels.set((int) event.getX(), (int) event.getY());
    WorkspacePoint curDragPositionWorkspace = mTempWorkspacePoint;
    mViewHelper.virtualViewToWorkspaceCoordinates(
            curDragLocationPixels, curDragPositionWorkspace);

    WorkspacePoint touchDownWorkspace = mPendingDrag.getTouchDownWorkspaceCoordinates();
    // Subtract original drag location from current location to get delta
    float workspaceDeltaX = curDragPositionWorkspace.x - touchDownWorkspace.x;
    float workspaceDeltaY = curDragPositionWorkspace.y - touchDownWorkspace.y;

    WorkspacePoint blockOrigPosition = mPendingDrag.getOriginalBlockPosition();
    mPendingDrag.getRootDraggedBlock().setPosition(blockOrigPosition.x + workspaceDeltaX,
                                            blockOrigPosition.y + workspaceDeltaY);
    mPendingDrag.getDragGroup().requestLayout();
}
项目:Blockly    文件:TrashCanView.java   
@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);
}
项目:LaunchTime    文件:QuickRow.java   
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);
            }
        });
    }
项目:Rotatable-Scalable-Font    文件:WidgetTextInputDialog.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setWindowAnimations(R.style.animation_baseDialog);
    setContentView(R.layout.video_edit_text_input);

    mEditText = (EditText) findViewById(android.R.id.edit);
    mConfirmButton = (ImageView) findViewById(R.id.text_edit_confirm_button);
    mBackImg = (ImageView) findViewById(R.id.back_img);

    mEditText.setText(mExistText);
    mEditText.setSelection(mExistText.length());
    mEditText.setOnDragListener(new View.OnDragListener() {
        @Override
        public boolean onDrag(View v, DragEvent event) {
            return true;
        }
    });
}
项目:rview    文件:AttachmentDropView.java   
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
    switch (dragEvent.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            AttachmentsProvider provider =
                    AttachmentsProviderFactory.getAttachmentProvider(getContext());
            return mCallback != null && provider.isSupported();
        case DragEvent.ACTION_DRAG_ENTERED:
            setBackgroundColor(ContextCompat.getColor(getContext(), R.color.attachmentOverlay));
            return isValidDragEvent(dragEvent.getClipData());
        case DragEvent.ACTION_DRAG_ENDED:
            setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
            return true;
        case DragEvent.ACTION_DRAG_EXITED:
        case DragEvent.ACTION_DRAG_LOCATION:
            return true;
        case DragEvent.ACTION_DROP:
            if (isValidDragEvent(dragEvent.getClipData())) {
                final List<Attachment> attachments = extractAttachments(dragEvent.getClipData());
                post(() -> mCallback.onAttachmentsDropped(attachments));
                return true;
            }
            // Fallback
    }
    return false;
}
项目:talk-android    文件:RecipientEditTextView.java   
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
项目:talk-android    文件:TextChipsEditView.java   
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
项目:openlauncher    文件:DragOptionView.java   
@Override
public boolean dispatchDragEvent(DragEvent ev) {
    final DragEvent event = ev;
    boolean r = super.dispatchDragEvent(ev);
    if (r && (ev.getAction() == DragEvent.ACTION_DRAG_STARTED || ev.getAction() == DragEvent.ACTION_DRAG_ENDED)) {
        // If we got a start or end and the return value is true, our
        // onDragEvent wasn't called by ViewGroup.dispatchDragEvent
        // So we do it here.
        this.post(new Runnable() {
            @Override
            public void run() {
                onDragEvent(event);
            }
        });


        // fix crash on older versions of android
        try {
            super.dispatchDragEvent(ev);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }
    return r;
}
项目:AndroidChromium    文件:CompositorViewHolder.java   
@Override
public boolean dispatchDragEvent(DragEvent e) {
    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null) return false;

    if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
    contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    boolean ret = super.dispatchDragEvent(e);

    int action = e.getAction();
    if (action == DragEvent.ACTION_DRAG_EXITED || action == DragEvent.ACTION_DRAG_ENDED
            || action == DragEvent.ACTION_DROP) {
        contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
    }
    return ret;
}
项目:toshi-android-client    文件:DragAndDropView.java   
private boolean handleDragEvent(final View v, final DragEvent event) {
    switch(event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
        case DragEvent.ACTION_DRAG_ENTERED:
        case DragEvent.ACTION_DRAG_LOCATION:
        case DragEvent.ACTION_DRAG_EXITED:
        case DragEvent.ACTION_DRAG_ENDED:
            return true;

        case DragEvent.ACTION_DROP:
            final String phrase = event.getClipData().getItemAt(0).getText().toString();
            moveViewToCorrectLocationFromDrag(v, phrase);
            return true;

        default:
            return false;
    }
}
项目:Tada    文件:TextView.java   
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            return mEditor != null && mEditor.hasInsertionController();

        case DragEvent.ACTION_DRAG_ENTERED:
            TextView.this.requestFocus();
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            final int offset = getOffsetForPosition(event.getX(), event.getY());
            Selection.setSelection((Spannable)mText, offset);
            return true;

        case DragEvent.ACTION_DROP:
            if (mEditor != null) mEditor.onDrop(event);
            return true;

        case DragEvent.ACTION_DRAG_ENDED:
        case DragEvent.ACTION_DRAG_EXITED:
        default:
            return true;
    }
}
项目:365browser    文件:CompositorViewHolder.java   
@Override
public boolean dispatchDragEvent(DragEvent e) {
    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null) return false;

    if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
    contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    boolean ret = super.dispatchDragEvent(e);

    int action = e.getAction();
    if (action == DragEvent.ACTION_DRAG_EXITED || action == DragEvent.ACTION_DRAG_ENDED
            || action == DragEvent.ACTION_DROP) {
        contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
    }
    return ret;
}
项目:DraggedViewPager    文件:DragUtils.java   
/**
 * 获取拖拽触发的执行事件类型
 *
 * @param draggedViewPager 最外层 {@link com.bigfat.draggedviewpager.view.MDA_DraggedViewPager}
 * @param currentPageIndex 当前页索引
 * @param pageIndex        响应拖拽事件item所在页索引
 * @param view             响应拖拽事件的item
 * @param event            拖拽事件
 * @return 拖拽事件类型
 */
public static DragEventType getDragEventType(MDA_DraggedViewPager draggedViewPager, int currentPageIndex, int pageIndex,
    View view, DragEvent event) {
    if (currentPageIndex > 0//有上一页
        && (draggedViewPager.getPageDragSetting() == null || draggedViewPager.getPageDragSetting()
        .canBeSwiped(currentPageIndex - 1))//上一页可被交换
        //触摸至上一页//或至触摸至当前页左边界,则切换到上一页
        && (pageIndex < currentPageIndex || (pageIndex == currentPageIndex && event.getX() < view.getWidth() / 8))) {
        return DragEventType.SCROLL_PREVIOUS;
    } else if (currentPageIndex < (draggedViewPager.getContainer().getChildCount() - 1)//在有下一页的前提下
        && (draggedViewPager.getPageDragSetting() == null || draggedViewPager.getPageDragSetting()
        .canBeSwiped(currentPageIndex + 1))//下一页可被交换
        //触摸至下一页//或至触摸至当前页右边界,则切换到下一页
        && (pageIndex > currentPageIndex || (pageIndex == currentPageIndex && event.getX() > view.getWidth() / 8 * 7))) {
        return DragEventType.SCROLL_NEXT;
    }
    return DragEventType.DEFAULT;
}
项目:cordova-mapbox-android-sdk    文件:Builder.java   
private boolean dragLocation(View v, DragEvent event) {
  Projection p = mapView.getProjection();
  LatLng latLng = (LatLng) p.fromPixels(event.getX(), event.getY());

  this.activeVertex.getOwner().setLatLng(this.activeIndex, latLng);
  // Let implementing classes perform reset action.
  this.activeVertex.getOwner().reset();

  Vertex vertex = vertices.get(selected);
  Vertex prev = vertex.getPrev();
  Vertex next = vertex.getNext();

  if (prev != null && !prev.equals(vertex)) {
    vertex.getMiddleLeft().setPoint(getMiddleLatLng(prev.getPoint(), latLng));
  }

  if (next != null && !next.equals(vertex)) {
    vertex.getMiddleRight().setPoint(getMiddleLatLng(latLng, next.getPoint()));
  }

  // Invalidating the view causes a redraw.
  v.invalidate();
  return true;
}
项目:cordova-mapbox-android-sdk    文件:Builder.java   
public boolean onDrag(View v, DragEvent event) {
  final int action = event.getAction();

  switch (action) {
    case DragEvent.ACTION_DRAG_STARTED:
      return dragStart(v, event);
    case DragEvent.ACTION_DRAG_ENTERED:
      return true;
    case DragEvent.ACTION_DRAG_LOCATION:
      return this.dragLocation(v, event);
    case DragEvent.ACTION_DRAG_EXITED:
      return true;
    case DragEvent.ACTION_DROP:
      return this.dragDrop(v, event);
    case DragEvent.ACTION_DRAG_ENDED:
      return true;
    default:
      Log.e("MarkerDragEventListener", "Unknown action type received by OnDragListener.");
      break;
  }
  return false;
}
项目:DistroHopper    文件:LauncherDragListener.java   
@Override
public boolean onDrag (View view, DragEvent event)
{
    try
    {
        switch (event.getAction ())
        {
            case DragEvent.ACTION_DRAG_ENTERED:
                this.appManager.startedDraggingPinnedApp ();
                break;
            case DragEvent.ACTION_DROP:
            case DragEvent.ACTION_DRAG_EXITED:
                this.appManager.stoppedDraggingPinnedApp ();
                break;
        }
    }
    catch (Exception ex)
    {
        ExceptionHandler exh = new ExceptionHandler (this.appManager.getContext (), ex);
        exh.show ();
    }

    return true;
}
项目:ClubHelperAndroid    文件:PersonDetailFragment.java   
private TableRow createNewTableRow() {
    TableRow row = new TableRow(getActivity()) {
        @Override
        public boolean dispatchDragEvent(DragEvent ev) {
            boolean r = super.dispatchDragEvent(ev);
            if (r && (ev.getAction() == DragEvent.ACTION_DRAG_STARTED || ev.getAction() == DragEvent.ACTION_DRAG_ENDED)) {
                // If we got a start or end and the return value is true,
                // our
                // onDragEvent wasn't called by ViewGroup.dispatchDragEvent
                // So we do it here.
                onDragEvent(ev);
            }
            return r;
        }
    };
    row.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
    row.setPadding(2, 5, 5, 2);
    return row;
}
项目:sms_DualCard    文件:RecipientEditTextView.java   
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
项目:SimpleKiwixWikivoyage    文件:KiwixMobileFragment.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setUpTabDeleteCross() {

    mTabDeleteCross.setOnDragListener(new View.OnDragListener() {
        @Override
        public boolean onDrag(View v, DragEvent event) {

            switch (event.getAction()) {

                case DragEvent.ACTION_DROP:
                    int tabPosition = mFragmentCommunicator.getPositionOfTab();
                    mFragmentCommunicator.removeTabAt(tabPosition);

                case DragEvent.ACTION_DRAG_ENDED:
                    mTabDeleteCross.startAnimation(
                            AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
                    mTabDeleteCross.setVisibility(View.INVISIBLE);
                    mTabDeleteCross.getBackground().clearColorFilter();
            }
            return true;
        }
    });
}
项目:amddviews    文件:AdaptableDragDropView.java   
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
    case DragEvent.ACTION_DRAG_STARTED:
        //Log.i(TAG, "Drag Started.");
        return onDragStarted(event);
    case DragEvent.ACTION_DRAG_ENTERED:
        Log.i(TAG, "Drag entered ADDV");
        return onDragEntered(event);
    case DragEvent.ACTION_DRAG_LOCATION:
        return onDragMoveOn(event);
    case DragEvent.ACTION_DRAG_EXITED:
        Log.i(TAG, "Drag exited ADDV");
        return onDragExited(event);
    case DragEvent.ACTION_DROP:
        Log.i(TAG, "Drag droped ADDV");
        return onDrop(event);
    case DragEvent.ACTION_DRAG_ENDED:
        //Log.i(TAG, "Drag ended ADDV.");
        return onDragEnded(event);
    }

    return super.onDragEvent(event);
}
项目:amddviews    文件:DropableListView.java   
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
    case DragEvent.ACTION_DRAG_STARTED:
        //Log.i(TAG, "DropLV Drag Started.");
        return onDragStarted(event);
    case DragEvent.ACTION_DRAG_ENTERED:
        Log.i(TAG, "Drag entered DropLV.");
        return onDragEntered(event);
    case DragEvent.ACTION_DRAG_LOCATION:
        return onDragMoveOn(event);
    case DragEvent.ACTION_DRAG_EXITED:
        Log.i(TAG, "Drag exited DropLV.");
        return onDragExited(event);
    case DragEvent.ACTION_DROP:
        Log.i(TAG, "Drag droped DropLV.");
        return onDrop(event);
    case DragEvent.ACTION_DRAG_ENDED:
        //Log.i(TAG, "DropLV Drag ended.");
        return onDragEnded(event);
    }

    return super.onDragEvent(event);
}
项目:amddviews    文件:DropableListView.java   
private boolean findAppropriateDropHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:"
            + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(TAG, "DLV Drag location relative, x: " + mDragLocationOnScreen[0]
            + " y: " + mDragLocationOnScreen[1]);

    if (mCurrentDropHandleView != null) {
        ((DropAcceptable) mCurrentDropHandleView).onDrop(event);
        mCurrentDropHandleView = null;
        return true;
    } else {
        return false;
    }
}
项目:amddviews    文件:DropableGridView.java   
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
    case DragEvent.ACTION_DRAG_STARTED:
        //Log.i(TAG, "DropGV Drag Started.");
        return onDragStarted(event);
    case DragEvent.ACTION_DRAG_ENTERED:
        Log.i(TAG, "Drag entered DropGV.");
        return onDragEntered(event);
    case DragEvent.ACTION_DRAG_LOCATION:
        return onDragMoveOn(event);
    case DragEvent.ACTION_DRAG_EXITED:
        Log.i(TAG, "Drag exited DropGV");
        return onDragExited(event);
    case DragEvent.ACTION_DROP:
        Log.i(TAG, "Drag droped DropGV");
        return onDrop(event);
    case DragEvent.ACTION_DRAG_ENDED:
        //Log.i(TAG, "Drag ended DropGV.");
        return onDragEnded(event);
    }

    return super.onDragEvent(event);
}
项目:amddviews    文件:DropableGridView.java   
private boolean findAppropriateDropHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:"
            + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(TAG, "DGV Drag location relative, x: " + mDragLocationOnScreen[0]
            + " y: " + mDragLocationOnScreen[1]);

    if (mCurrentDropHandleView != null) {
        ((DropAcceptable) mCurrentDropHandleView).onDrop(event);
        mCurrentDropHandleView = null;
        return true;
    } else {
        return false;
    }
}
项目:androidProject    文件:Workspace.java   
/**
 * Tests to see if the drop will be accepted by Launcher, and if so, includes additional data
 * in the returned structure related to the widgets that match the drop (or a null list if it is
 * a shortcut drop).  If the drop is not accepted then a null structure is returned.
 */
private Pair<Integer, List<WidgetMimeTypeHandlerData>> validateDrag(DragEvent event) {
    final LauncherModel model = mLauncher.getModel();
    final ClipDescription desc = event.getClipDescription();
    final int mimeTypeCount = desc.getMimeTypeCount();
    for (int i = 0; i < mimeTypeCount; ++i) {
        final String mimeType = desc.getMimeType(i);
        if (mimeType.equals(InstallShortcutReceiver.SHORTCUT_MIMETYPE)) {
            return new Pair<Integer, List<WidgetMimeTypeHandlerData>>(i, null);
        } else {
            final List<WidgetMimeTypeHandlerData> widgets =
                model.resolveWidgetsForMimeType(mContext, mimeType);
            if (widgets.size() > 0) {
                return new Pair<Integer, List<WidgetMimeTypeHandlerData>>(i, widgets);
            }
        }
    }
    return null;
}
项目:Calendar_lunar    文件:RecipientEditTextView.java   
/**
 * Handles drag event.
 */
@Override
public boolean onDragEvent(DragEvent event) {
    switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
            // Only handle plain text drag and drop.
            return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        case DragEvent.ACTION_DRAG_ENTERED:
            requestFocus();
            return true;
        case DragEvent.ACTION_DROP:
            handlePasteClip(event.getClipData());
            return true;
    }
    return false;
}
项目:kitty-playground    文件:MyActivity.java   
@Override
public boolean onDrag(final View view, final DragEvent event) {
    //if (catView == null) return true;
    switch (event.getAction()) {
        case DragEvent.ACTION_DROP:
            final View dragView = (View)event.getLocalState();
            final int width = dragView.getWidth();
            final int height = dragView.getHeight();
            final int xPos = (int)(event.getX() - (width / 2));
            final int yPos = (int)(event.getY() - (height / 2));

            final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(width, height);
            layoutParams.setMargins(xPos, yPos, 0, 0);
            dragView.setLayoutParams(layoutParams);
            dragView.setVisibility(View.VISIBLE);
            catView = null;
            break;
    }
    return true;
}
项目:LaunchEnr    文件:DragDriver.java   
@Override
public boolean onDragEvent (DragEvent event) {
    final int action = event.getAction();

    switch (action) {
        case DragEvent.ACTION_DRAG_STARTED:
            mLastX = event.getX();
            mLastY = event.getY();
            return true;

        case DragEvent.ACTION_DRAG_ENTERED:
            return true;

        case DragEvent.ACTION_DRAG_LOCATION:
            mLastX = event.getX();
            mLastY = event.getY();
            mEventListener.onDriverDragMove(event.getX(), event.getY());
            return true;

        case DragEvent.ACTION_DROP:
            mLastX = event.getX();
            mLastY = event.getY();
            mEventListener.onDriverDragMove(event.getX(), event.getY());
            mEventListener.onDriverDragEnd(mLastX, mLastY);
            return true;
        case DragEvent.ACTION_DRAG_EXITED:
            mEventListener.onDriverDragExitWindow();
            return true;

        case DragEvent.ACTION_DRAG_ENDED:
            mEventListener.onDriverDragCancel();
            return true;

        default:
            return false;
    }
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Create {@link DragAndDropPermissions} object bound to this activity and controlling the
 * access permissions for content URIs associated with the {@link DragEvent}.
 * @param event Drag event
 * @return The {@link DragAndDropPermissions} object used to control access to the content URIs.
 * Null if no content URIs are associated with the event or if permissions could not be granted.
 */
public DragAndDropPermissions requestDragAndDropPermissions(DragEvent event) {
    DragAndDropPermissions dragAndDropPermissions = DragAndDropPermissions.obtain(event);
    if (dragAndDropPermissions != null && dragAndDropPermissions.take(getActivityToken())) {
        return dragAndDropPermissions;
    }
    return null;
}