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


Java MotionEvent.ACTION_DOWN屬性代碼示例

本文整理匯總了Java中android.view.MotionEvent.ACTION_DOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.ACTION_DOWN屬性的具體用法?Java MotionEvent.ACTION_DOWN怎麽用?Java MotionEvent.ACTION_DOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.MotionEvent的用法示例。


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

示例1: dispatchOnItemTouchIntercept

private boolean dispatchOnItemTouchIntercept(MotionEvent e) {
    final int action = e.getAction();
    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_DOWN) {
        mActiveOnItemTouchListener = null;
    }

    final int listenerCount = mOnItemTouchListeners.size();
    for (int i = 0; i < listenerCount; i++) {
        final OnItemTouchListener listener = mOnItemTouchListeners.get(i);
        if (listener.onInterceptTouchEvent(this, e) && action != MotionEvent.ACTION_CANCEL) {
            mActiveOnItemTouchListener = listener;
            return true;
        }
    }
    return false;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:16,代碼來源:RecyclerView.java

示例2: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (mCanClick) {
                mCanClick = false;
                if (mStatus == STATUS_NORMAL) {
                    mStatus = STATUS_PRESS;
                    startPressStatusAnimation();
                } else {
                    resetStatus();
                }
            }
            break;
        case MotionEvent.ACTION_UP:
            if (mStatus == STATUS_PRESS) {
                mStatus = STATUS_PRESS_RELEASE;
                startPressReleaseStatusAnimation();
            }
            break;
    }
    return true;
}
 
開發者ID:arjinmc,項目名稱:AndroidButtonLib,代碼行數:24,代碼來源:SubmitButton.java

示例3: analyzeTouchToMaximizeIfNeeded

private void analyzeTouchToMaximizeIfNeeded(MotionEvent ev, boolean isDragViewHit) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            lastTouchActionDownXPosition = ev.getX();
            break;
        case MotionEvent.ACTION_UP:
            float clickOffset = ev.getX() - lastTouchActionDownXPosition;
            if (shouldMaximizeOnClick(ev, clickOffset, isDragViewHit)) {
                if (isMinimized() && isClickToMaximizeEnabled()) {
                    maximize();
                } else if (isMaximized() && isClickToMinimizeEnabled()) {
                    minimize();
                }
            }
            break;
        default:
            break;
    }
}
 
開發者ID:mugku,項目名稱:slidingplayersampleapp,代碼行數:19,代碼來源:SlidingViewK.java

示例4: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mIsLoadDataComplete) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mStartY = ev.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                if (Math.abs(mStartY - ev.getY()) > 15) {
                    mTvTime.removeCallbacks(mHideAnimTask);
                    if (mTvTime.getVisibility() == View.GONE || mHideTimeAnim.isRunning()) {
                        mHideTimeAnim.cancel();
                        mShowTimeAnim.start();
                    }
                    setTvTimeText();
                }
                break;
        }
    }
    return super.dispatchTouchEvent(ev);
}
 
開發者ID:liuke2016,項目名稱:filepicker,代碼行數:21,代碼來源:BasePickerActivity.java

示例5: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent e) {
    switch (e.getAction()) {
        case MotionEvent.ACTION_DOWN:
            lastY = (int) e.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            int y = (int) (e.getRawY());
            int dy = y - lastY;
            lastY = y;

            if (startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL) //如果找到了支持嵌套滾動的父類
                    && dispatchNestedPreScroll(0, dy, consumed, offset)) {//父類進行了一部分滾動

                int remain = dy - consumed[1];//獲取滾動的剩餘距離
                if (remain != 0) {
                    scrollBy(0, -remain);
                }

            } else {
                scrollBy(0, -dy);
            }
    }

    return true;
}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:26,代碼來源:MyNestedScrollChild.java

示例6: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        if (isTouchView(filterViewByIds(), ev)) return super.dispatchTouchEvent(ev);
        if (hideSoftByEditViewIds() == null || hideSoftByEditViewIds().length == 0)
            return super.dispatchTouchEvent(ev);
        View v = getCurrentFocus();
        if (isFocusEditText(v, hideSoftByEditViewIds())) {
            if (isTouchView(hideSoftByEditViewIds(), ev))
                return super.dispatchTouchEvent(ev);
            //隱藏鍵盤
            KeyBoardUtils.hideInputForce(this);
            clearViewFocus(v, hideSoftByEditViewIds());

        }
    }
    return super.dispatchTouchEvent(ev);

}
 
開發者ID:zybieku,項目名稱:SoftKeyboardUtil,代碼行數:19,代碼來源:BaseActivity.java

示例7: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            xDistance = yDistance = 0f;
            lastX = ev.getX();
            lastY = ev.getY();
            break;
        case MotionEvent.ACTION_MOVE:
            final float curX = ev.getX();
            final float curY = ev.getY();
            xDistance += Math.abs(curX - lastX);
            yDistance += Math.abs(curY - lastY);
            lastX = curX;
            lastY = curY;
            if(xDistance > yDistance)
                return false;
    }

    return super.onInterceptTouchEvent(ev);
}
 
開發者ID:PaulKlinger,項目名稱:Sprog-App,代碼行數:21,代碼來源:VerticalScrollView.java

示例8: onTouch

@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View view, MotionEvent event) {
    boolean isTouchEventConsumed = false;

    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mIsTouchEventsBeingProcessed = true;
            isTouchEventConsumed |= true;
            view.setPressed(true);
            showAppMenu(view, true);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsTouchEventsBeingProcessed = false;
            isTouchEventConsumed |= true;
            view.setPressed(false);
            break;
        default:
    }

    // If user starts to drag on this menu button, ACTION_DOWN and all the subsequent touch
    // events are received here. We need to forward this event to the app menu to handle
    // dragging correctly.
    AppMenuDragHelper dragHelper = mMenuHandler.getAppMenuDragHelper();
    if (dragHelper != null) {
        isTouchEventConsumed |= dragHelper.handleDragging(event, view);
    }
    return isTouchEventConsumed;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:30,代碼來源:AppMenuButtonHelper.java

示例9: onTouchEvent

public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // If down event occurs inside index bar region, start indexing
            if (mState != STATE_HIDDEN && contains(ev.getX(), ev.getY())) {
                setState(STATE_SHOWN);

                // It demonstrates that the motion event started from index bar
                mIsIndexing = true;
                // Determine which section the point is in, and move the list to that section
                mCurrentSection = getSectionByPoint(ev.getY());
                mListView.setSelection(mIndexer.getPositionForSection(mCurrentSection));
                return true;
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (mIsIndexing) {
                // If this event moves inside index bar
                if (contains(ev.getX(), ev.getY())) {
                    // Determine which section the point is in, and move the list to that section
                    mCurrentSection = getSectionByPoint(ev.getY());
                    mListView.setSelection(mIndexer.getPositionForSection(mCurrentSection));
                }
                return true;
            }
            break;
        case MotionEvent.ACTION_UP:
            if (mIsIndexing) {
                mIsIndexing = false;
                mCurrentSection = -1;
            }
            if (mState == STATE_SHOWN)
                setState(STATE_HIDING);
            break;
    }
    return false;
}
 
開發者ID:jathak,項目名稱:sflauncher,代碼行數:37,代碼來源:IndexScroller.java

示例10: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            //用戶按下到下一個鏈接加載之前,置為true
            mTouchByUser = true;
            break;
    }
    return super.onTouchEvent(event);
}
 
開發者ID:yangchong211,項目名稱:YCUtils,代碼行數:10,代碼來源:ScrollWebView.java

示例11: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    mScroller.forceFinished(true);
    int type = MotionEventCompat.getActionMasked(ev);
    float currentX = MotionEventCompat.getX(ev, 0);
    float currentY = MotionEventCompat.getY(ev, 0);

    switch (type) {
        case MotionEvent.ACTION_DOWN:
            downX = currentX;
            downY = currentY;

            float x = firstView.getX() + firstView.getMeasuredWidth() / 2.0f;
            float y = firstView.getY() + firstView.getMeasuredHeight() / 2.0f;

            lastAngle = (float) getRelativeAngle(x, y);
            break;
        case MotionEvent.ACTION_MOVE:
            float distance = getDistance(downX, downY, currentX, currentY);
            if (distance > ViewConfiguration.getTouchSlop()) {
                return true;
            }
            break;
        case MotionEvent.ACTION_UP:

            break;
    }

    return false;
}
 
開發者ID:tortuvshin,項目名稱:sign-android,代碼行數:30,代碼來源:CircleMenu.java

示例12: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    int action = ev.getAction();
    float x = ev.getRawX();
    float y = ev.getRawY();

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            xDown = x;
            yDown = y;
            break;
        case MotionEvent.ACTION_MOVE:
            int xDistance = (int) (x - xDown);
            int yDistance = (int) (y - yDown);

            if (Math.abs(xDistance) > touchSlop && Math.abs(xDistance) > Math.abs(yDistance)) {
                if (!recyclerView.canScrollHorizontally(-1) && xDistance > 0
                        || (!recyclerView.canScrollHorizontally(1) && xDistance < 0)) {
                    enableOverScrollPull = true;
                    return true;
                } else {
                    enableOverScrollPull = false;
                }
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            if (enableOverScrollPull) {
                return true;
            }
            break;
        default:
            break;
    }

    return false;
}
 
開發者ID:alibaba,項目名稱:Tangram-Android,代碼行數:38,代碼來源:LinearScrollView.java

示例13: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, TextView child, MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            downReach = false;
            upReach = false;
            break;
    }
    return super.onInterceptTouchEvent(parent, child, ev);
}
 
開發者ID:Othershe,項目名稱:BehaviorDemo,代碼行數:10,代碼來源:SampleHeaderBehavior.java

示例14: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {

        case MotionEvent.ACTION_DOWN:
            downX = event.getX();
            break;

        case MotionEvent.ACTION_MOVE:

            moveX = event.getX();
            //if is not scrolling
            if (Math.abs(downX - moveX) >= touchSlop) {
                isScrolling = true;
                int alterMove = (int) (downX - moveX);

                if (getScrollX() + alterMove <= leftBorder) {
                    scrollTo((int) leftBorder, 0);
                } else {
                    scrollTo(getScrollX() + alterMove, 0);
                }
            }
            break;

        case MotionEvent.ACTION_UP:
            if (isScrolling == true) {
                scroller.startScroll(getScrollX(), 0, getScrollX() + (int) (moveX - downX), 0, 2000);
                invalidate();
            }

            break;
    }
    return true;
}
 
開發者ID:arjinmc,項目名稱:DateScroller,代碼行數:34,代碼來源:DateScrollerView.java

示例15: onTouchEvent

/**
 * <ul>
 * if stopScrollWhenTouch is true
 * <li>if event is down, stop auto scroll.</li>
 * <li>if event is up, start auto scroll again.</li>
 * </ul>
 */
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (stopScrollWhenTouch) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN && isAutoScroll) {
            isStopByTouch = true;
            stopAutoScroll();
        } else if (ev.getAction() == MotionEvent.ACTION_UP && isStopByTouch) {
            startAutoScroll();
        }
    }

    if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT || slideBorderMode == SLIDE_BORDER_MODE_CYCLE) {
        touchX = ev.getX();
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            downX = touchX;
        }
        int currentItem = getCurrentItem();
        PagerAdapter adapter = getAdapter();
        int pageCount = adapter == null ? 0 : adapter.getCount();
        /**
         * current index is first one and slide to right or current index is last one and slide to left.<br/>
         * if slide border mode is to parent, then requestDisallowInterceptTouchEvent false.<br/>
         * else scroll to last one when current item is first one, scroll to first one when current item is last
         * one.
         */
        if ((currentItem == 0 && downX <= touchX) || (currentItem == pageCount - 1 && downX >= touchX)) {
            if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT) {
                getParent().requestDisallowInterceptTouchEvent(false);
            } else {
                if (pageCount > 1) {
                    setCurrentItem(pageCount - currentItem - 1, isBorderAnimation);
                }
                getParent().requestDisallowInterceptTouchEvent(true);
            }
            return super.onTouchEvent(ev);
        }
    }
    getParent().requestDisallowInterceptTouchEvent(true);
    return super.onTouchEvent(ev);
}
 
開發者ID:tranleduy2000,項目名稱:text_converter,代碼行數:47,代碼來源:AutoScrollViewPager.java


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