當前位置: 首頁>>代碼示例>>Java>>正文


Java DragEvent類代碼示例

本文整理匯總了Java中android.view.DragEvent的典型用法代碼示例。如果您正苦於以下問題:Java DragEvent類的具體用法?Java DragEvent怎麽用?Java DragEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DragEvent類屬於android.view包,在下文中一共展示了DragEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDrag

import android.view.DragEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:17,代碼來源:PinItemDragListener.java

示例2: recordDragEvent

import android.view.DragEvent; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:25,代碼來源:FlingToDeleteHelper.java

示例3: dispatchDragEvent

import android.view.DragEvent; //導入依賴的package包/類
@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;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:17,代碼來源:CompositorViewHolder.java

示例4: continueDragging

import android.view.DragEvent; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:24,代碼來源:Dragger.java

示例5: updateBlockPosition

import android.view.DragEvent; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:26,代碼來源:Dragger.java

示例6: setOnDragListener

import android.view.DragEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:27,代碼來源:TrashCanView.java

示例7: QuickRow

import android.view.DragEvent; //導入依賴的package包/類
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);
            }
        });
    }
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:17,代碼來源:QuickRow.java

示例8: onCreate

import android.view.DragEvent; //導入依賴的package包/類
@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;
        }
    });
}
 
開發者ID:MaYatKit,項目名稱:Rotatable-Scalable-Font,代碼行數:21,代碼來源:WidgetTextInputDialog.java

示例9: onDrag

import android.view.DragEvent; //導入依賴的package包/類
@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;
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:27,代碼來源:AttachmentDropView.java

示例10: onDragEvent

import android.view.DragEvent; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:19,代碼來源:RecipientEditTextView.java

示例11: dispatchDragEvent

import android.view.DragEvent; //導入依賴的package包/類
@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;
}
 
開發者ID:OpenLauncherTeam,項目名稱:openlauncher,代碼行數:26,代碼來源:DragOptionView.java

示例12: handleDragEvent

import android.view.DragEvent; //導入依賴的package包/類
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;
    }
}
 
開發者ID:toshiapp,項目名稱:toshi-android-client,代碼行數:19,代碼來源:DragAndDropView.java

示例13: onDragEvent

import android.view.DragEvent; //導入依賴的package包/類
@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;
    }
}
 
開發者ID:AungThiha,項目名稱:Tada,代碼行數:26,代碼來源:TextView.java

示例14: getDragEventType

import android.view.DragEvent; //導入依賴的package包/類
/**
 * 獲取拖拽觸發的執行事件類型
 *
 * @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;
}
 
開發者ID:yueban,項目名稱:DraggedViewPager,代碼行數:28,代碼來源:DragUtils.java

示例15: dragLocation

import android.view.DragEvent; //導入依賴的package包/類
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;
}
 
開發者ID:affinitybridge,項目名稱:cordova-mapbox-android-sdk,代碼行數:25,代碼來源:Builder.java


注:本文中的android.view.DragEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。