Example usage for android.view MotionEvent ACTION_MOVE

List of usage examples for android.view MotionEvent ACTION_MOVE

Introduction

In this page you can find the example usage for android.view MotionEvent ACTION_MOVE.

Prototype

int ACTION_MOVE

To view the source code for android.view MotionEvent ACTION_MOVE.

Click Source Link

Document

Constant for #getActionMasked : A change has happened during a press gesture (between #ACTION_DOWN and #ACTION_UP ).

Usage

From source file:com.bluepixel.android.sgpool.ui.widget.SwipeRefreshLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTarget();/*  www .j  a  va2 s  . com*/

    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }

    if (!isEnabled() || mReturningToStart || canChildScrollUp()) {
        // Fail fast if we're not in a state where a swipe is possible
        return false;
    }

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mLastMotionY = mInitialMotionY = ev.getY();
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mIsBeingDragged = false;
        mCurrPercentage = 0;
        break;

    case MotionEvent.ACTION_MOVE:
        if (mActivePointerId == INVALID_POINTER) {
            Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
            return false;
        }

        final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        if (pointerIndex < 0) {
            Log.e(LOG_TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
            return false;
        }

        final float y = MotionEventCompat.getY(ev, pointerIndex);
        final float yDiff = y - mInitialMotionY;
        if (yDiff > mTouchSlop) {
            mLastMotionY = y;
            mIsBeingDragged = true;
        }
        break;

    case MotionEventCompat.ACTION_POINTER_UP:
        onSecondaryPointerUp(ev);
        break;

    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        mIsBeingDragged = false;
        mCurrPercentage = 0;
        mActivePointerId = INVALID_POINTER;
        break;
    }

    return mIsBeingDragged;
}

From source file:com.example.SmartBoard.DrawingView.java

public boolean drawPoint(float x, float y, int action, int color, String mode, int brushSize, String clientID) {

    mX = x;//  w w  w  . j  a  va 2 s .  co  m
    mY = y;

    Path path = clientPaths.get(clientID);
    if (path == null) {
        path = new Path();
        clientPaths.put(clientID, path);
    }
    drawPathRecv = path;

    setDrawPaintRecv(color, mode, brushSize);
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        drawPathRecv.moveTo(x, y);
        break;
    case MotionEvent.ACTION_MOVE:
        drawPathRecv.lineTo(x, y);
        break;
    case MotionEvent.ACTION_UP:
        drawCanvas.drawPath(drawPathRecv, drawPaintSender);
        drawPathRecv.reset();
        break;
    case CLEAR_SCREEN:
        drawCanvas.drawColor(Color.WHITE);
        break;
    default:
        //draw nothing
    }

    invalidate();
    return true;
}

From source file:com.edible.ocr.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    checkFirstLaunch();//  w  ww .  j  a va2s.  c  om

    if (isFirstLaunch) {
        setDefaultPreferences();
    }
    currentContext = this;
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.capture);
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    cameraButtonView = findViewById(R.id.camera_button_view);
    resultView = findViewById(R.id.result_view);

    statusViewBottom = (TextView) findViewById(R.id.status_view_bottom);
    registerForContextMenu(statusViewBottom);
    statusViewTop = (TextView) findViewById(R.id.status_view_top);
    registerForContextMenu(statusViewTop);
    handler = null;
    lastResult = null;
    hasSurface = false;
    beepManager = new BeepManager(this);

    // Camera shutter button
    if (DISPLAY_SHUTTER_BUTTON) {
        shutterButton = (ShutterButton) findViewById(R.id.shutter_button);
        shutterButton.setOnShutterButtonListener(this);

    }
    settingButton = (Button) findViewById(R.id.setting_button);
    settingButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, PreferencesActivity.class);
            startActivity(intent);
        }
    });

    aboutButton = (Button) findViewById(R.id.about_button);
    aboutButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, HelpActivity.class);
            intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, HelpActivity.ABOUT_PAGE);
            startActivity(intent);
        }
    });
    final EditText editText = (EditText) findViewById(R.id.typed_result);
    editText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // add capture button function 
                Intent openDetail = new Intent(currentContext, DetailInfo.class);
                String req = editText.getText().toString();
                //             openDetail.putExtra("request", "Filet Steak");
                openDetail.putExtra("request", req);
                editText.setText("");
                startActivity(openDetail);
                handled = true;
            }
            return handled;
        }
    });
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    //DB_textview = (TextView)findViewById(R.id.DB_text_view);
    //new HttpAsyncTask().execute("https://www.googleapis.com/language/translate/v2?key=" + KEY + "&q=hello%20world&source=en&target=de");
    /* For Client Server Connection */
    getButton = (Button) findViewById(R.id.get_text_button);
    getButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent openDetail = new Intent(currentContext, DetailInfo.class);
            String req = (String) ocrResultView.getText();
            //         openDetail.putExtra("request", "Filet Steak");
            openDetail.putExtra("request", req);
            startActivity(openDetail);

        }

    });
    ocrResultView = (TextView) findViewById(R.id.ocr_result_text_view);
    registerForContextMenu(ocrResultView);
    translationView = (TextView) findViewById(R.id.translation_text_view);
    registerForContextMenu(translationView);

    progressView = (View) findViewById(R.id.indeterminate_progress_indicator_view);

    cameraManager = new CameraManager(getApplication());
    viewfinderView.setCameraManager(cameraManager);

    // Set listener to change the size of the viewfinder rectangle.
    viewfinderView.setOnTouchListener(new View.OnTouchListener() {
        int lastX = -1;
        int lastY = -1;

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                lastX = -1;
                lastY = -1;
                return true;
            case MotionEvent.ACTION_MOVE:
                int currentX = (int) event.getX();
                int currentY = (int) event.getY();

                try {
                    Rect rect = cameraManager.getFramingRect();

                    final int BUFFER = 50;
                    final int BIG_BUFFER = 60;
                    if (lastX >= 0) {
                        // Adjust the size of the viewfinder rectangle. Check if the touch event occurs in the corner areas first, because the regions overlap.
                        if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top left corner: adjust both top and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top right corner: adjust both top and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom left corner: adjust both bottom and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom right corner: adjust both bottom and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BUFFER && currentX <= rect.left + BUFFER)
                                || (lastX >= rect.left - BUFFER && lastX <= rect.left + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting left side: event falls within BUFFER pixels of left side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BUFFER && currentX <= rect.right + BUFFER)
                                || (lastX >= rect.right - BUFFER && lastX <= rect.right + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting right side: event falls within BUFFER pixels of right side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.top + BUFFER && currentY >= rect.top - BUFFER)
                                || (lastY <= rect.top + BUFFER && lastY >= rect.top - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting top side: event falls within BUFFER pixels of top side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.bottom + BUFFER && currentY >= rect.bottom - BUFFER)
                                || (lastY <= rect.bottom + BUFFER && lastY >= rect.bottom - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting bottom side: event falls within BUFFER pixels of bottom side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        }
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "Framing rect not available", e);
                }
                v.invalidate();
                lastX = currentX;
                lastY = currentY;
                return true;
            case MotionEvent.ACTION_UP:
                lastX = -1;
                lastY = -1;
                return true;
            }
            return false;
        }
    });

    isEngineReady = false;

}

From source file:com.android.launcher3.BubbleTextView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    // Call the superclass onTouchEvent first, because sometimes it changes the state to
    // isPressed() on an ACTION_UP
    boolean result = super.onTouchEvent(event);

    // Check for a stylus button press, if it occurs cancel any long press checks.
    if (mStylusEventHelper.onMotionEvent(event)) {
        mLongPressHelper.cancelLongPress();
        result = true;/*  w ww. j  a v a  2s.  co  m*/
    }

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        // So that the pressed outline is visible immediately on setStayPressed(),
        // we pre-create it on ACTION_DOWN (it takes a small but perceptible amount of time
        // to create it)
        if (!mDeferShadowGenerationOnTouch && mPressedBackground == null) {
            mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
        }

        // If we're in a stylus button press, don't check for long press.
        if (!mStylusEventHelper.inStylusButtonPressed()) {
            mLongPressHelper.postCheckForLongPress();
        }
        break;
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        // If we've touched down and up on an item, and it's still not "pressed", then
        // destroy the pressed outline
        if (!isPressed()) {
            mPressedBackground = null;
        }

        mLongPressHelper.cancelLongPress();
        break;
    case MotionEvent.ACTION_MOVE:
        if (!Utilities.pointInView(this, event.getX(), event.getY(), mSlop)) {
            mLongPressHelper.cancelLongPress();
        }
        break;
    }
    return result;
}

From source file:cn.bvin.app.swiperefresh.OldSwipeRefreshLayout.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    final int action = event.getAction();
    boolean handled = false;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mCurrPercentage = 0;/*from www  .j  a  v a 2s .  co  m*/
        mDownEvent = MotionEvent.obtain(event);
        mPrevY = mDownEvent.getY();
        break;
    case MotionEvent.ACTION_MOVE:
        if (mDownEvent != null && !mReturningToStart) {
            final float eventY = event.getY();
            float yDiff = eventY - mDownEvent.getY();
            if (yDiff > mTouchSlop) {//?
                // User velocity passed min velocity; trigger a refresh
                if (yDiff > mDistanceToTriggerSync) {//??
                    // User movement passed distance; trigger a refresh
                    startRefresh();
                    handled = true;
                    break;
                } else {
                    // Just track the user's movement
                    setTriggerPercentage(
                            mAccelerateInterpolator.getInterpolation(yDiff / mDistanceToTriggerSync));
                    float offsetTop = yDiff;
                    if (mPrevY > eventY) {
                        offsetTop = yDiff - mTouchSlop;
                    }
                    //content????
                    updateContentOffsetTop((int) (offsetTop * mResistance));
                    if (mPrevY > eventY && (mTarget.getTop() < mTouchSlop)) {
                        // If the user puts the view back at the top, we
                        // don't need to. This shouldn't be considered
                        // cancelling the gesture as the user can restart from the top.
                        removeCallbacks(mCancel);
                    } else {
                        updatePositionTimeout();
                    }
                    mPrevY = event.getY();
                    handled = true;
                }
            }
        }
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        if (mDownEvent != null) {
            mDownEvent.recycle();
            mDownEvent = null;
        }
        break;
    }
    return handled;
}

From source file:com.baitouwei.swiperefresh.ASwipeRefreshLayout.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (!isDragging) {
        return super.onTouchEvent(ev);
    }//from  ww w.  j  av  a2  s  .  co m

    final int action = MotionEventCompat.getActionMasked(ev);
    switch (action) {
    case MotionEvent.ACTION_MOVE:
        final float y = getMotionEventY(ev, activePointerId);
        final float dragOffset = (int) (y - initialMotionY);

        if (isSwipeStatusEnsure) {
            if ((dragOffset < 0 && isSwipeDown == true) || (dragOffset > 0 && isSwipeDown == false)) {
                return false;
            }
        }
        if (dragOffset > 0) {//SwipeDown,PS:dragPercent and dragOffset is positive
            if (headerView.getVisibility() != VISIBLE) {
                headerView.setVisibility(VISIBLE);
            }

            isSwipeDown = true;
            dragPercent = dragOffset / (contentViewSwipeDownOffsetRange);
            if (dampAbleOfSwipeDown) {
                int targetY = dampCompute(Math.abs(dragOffset * parallaxFactorOfContentSwipeDown),
                        contentViewSwipeDownOffsetRange, swipeDownDampRate);
                offsetContent(targetY - currentContentOffset, 1);
            } else {
                if (dragOffset < contentViewSwipeDownOffsetRange) {
                    offsetContent((int) dragOffset - currentContentOffset, parallaxFactorOfContentSwipeDown);
                }
            }
            offsetHeader((int) (dragPercent * headerView.getOffsetRange() - headerView.getCurrentOffset()));

            if (swipeLayoutConfigListener.isReadyToRefresh(this, dragOffset)) {
                headerView.updateStatus(SwipeStatus.READY);
            } else {
                headerView.updateStatus(SwipeStatus.NORMAL);
            }
            headerView.updatePercent(dragPercent);
        } else {//SwipeUp,PS:dragPercent and dragOffset is negative
            if (footerView.getVisibility() != VISIBLE) {
                footerView.setVisibility(VISIBLE);
            }

            isSwipeDown = false;
            dragPercent = dragOffset / (contentViewSwipeUpOffsetRange);

            if (dampAbleOfSwipeUp) {
                int targetY = dampCompute(Math.abs(dragOffset * parallaxFactorOfContentSwipeUp),
                        Math.abs(contentViewSwipeUpOffsetRange), swipeUpDampRate);
                offsetContent(-targetY - currentContentOffset, 1);
            } else {
                if (dragOffset > contentViewSwipeUpOffsetRange) {
                    offsetContent((int) dragOffset - currentContentOffset, parallaxFactorOfContentSwipeUp);
                }
            }
            offsetFooter((int) (dragPercent * footerView.getOffsetRange() - footerView.getCurrentOffset()));

            if (swipeLayoutConfigListener.isReadyToLoadMore(this, dragOffset)) {
                footerView.updateStatus(SwipeStatus.READY);
            } else {
                footerView.updateStatus(SwipeStatus.NORMAL);
            }
            footerView.updatePercent(dragPercent);
        }
        if (isSwipeStatusEnsure == false) {
            isSwipeStatusEnsure = true;
        }
        break;
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (isSwipeDown) {
            if (headerView.getSwipeStatus() == SwipeStatus.READY) {
                refreshStart();
            } else {
                animateContentOffsetToPos(true, true, new OnAnimateContentOffsetListener() {
                    @Override
                    public void onOffsetEnd() {
                        headerView.updateStatus(SwipeStatus.NORMAL);
                    }
                });
                animateHeaderOffsetToPos(true, new OnAnimateContentOffsetListener() {
                    @Override
                    public void onOffsetEnd() {
                        headerView.updateStatus(SwipeStatus.NORMAL);
                    }
                });
            }
        } else {
            if (footerView.getSwipeStatus() == SwipeStatus.READY) {
                loadMoreStart();
            } else {
                animateContentOffsetToPos(true, false, new OnAnimateContentOffsetListener() {
                    @Override
                    public void onOffsetEnd() {
                        footerView.updateStatus(SwipeStatus.NORMAL);
                    }
                });
                animateFooterOffsetToPos(true, new OnAnimateContentOffsetListener() {
                    @Override
                    public void onOffsetEnd() {
                        footerView.updateStatus(SwipeStatus.NORMAL);
                    }
                });
            }
        }

        isDragging = false;
        activePointerId = INVALID_POINTER;
        isSwipeStatusEnsure = false;
        break;
    }

    return true;
}

From source file:com.ayuget.redface.ui.activity.ReplyActivity.java

/**
 * Initializes both the smiley selector//from  www . ja v  a 2  s  .  c o m
 */
protected void setupSmileySelector() {
    smileyList.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int action = MotionEventCompat.getActionMasked(event);

            switch (action) {
            case MotionEvent.ACTION_DOWN: {
                final int pointerIndex = MotionEventCompat.getActionIndex(event);
                lastTouchY = MotionEventCompat.getY(event, pointerIndex);
                activePointerId = MotionEventCompat.getPointerId(event, 0);
                break;
            }
            case MotionEvent.ACTION_MOVE: {
                if (smileyList.getScrollY() == 0) {
                    final int pointerIndex = MotionEventCompat.findPointerIndex(event, activePointerId);

                    if (pointerIndex != -1) {
                        final float y = MotionEventCompat.getY(event, pointerIndex);

                        // Distance
                        float dy = y - lastTouchY;
                        isUpwardMovement = dy < 0;
                        float targetY = smileysSelector.getY() + dy;

                        if (targetY < toolbarHeight) {
                            float difference = toolbarHeight - targetY;
                            dy += difference;
                        } else if (targetY > smileySelectorTopOffset) {
                            float difference = targetY - smileySelectorTopOffset;
                            dy -= difference;
                        }

                        smileysSelector.setY(smileysSelector.getY() + dy);

                        // Show or hide the smileys toolbar based on current position
                        if (isUpwardMovement && smileysSelector.getY() < replyWindowMaxHeight) {
                            showSmileysToolbar();
                        } else {
                            hideSmileysToolbar();
                        }
                    }

                    break;
                }
            }
            case MotionEvent.ACTION_UP: {
                int upAnimationThreshold = replyWindowMaxHeight - toolbarHeight;

                float yTranslation;
                ViewPropertyAnimator viewPropertyAnimator = smileysSelector.animate();

                if (isUpwardMovement && smileysSelector.getY() == upAnimationThreshold) {
                    // Do not move in that case
                    yTranslation = 0;
                } else if (isUpwardMovement && smileysSelector.getY() < upAnimationThreshold) {
                    // Moving too far, let's avoid this
                    yTranslation = -(smileysSelector.getY() - toolbarHeight);
                } else {
                    // Replace the smiley selector at its original position
                    yTranslation = smileySelectorTopOffset - smileysSelector.getY();
                }

                if (yTranslation != 0) {
                    viewPropertyAnimator.translationYBy(yTranslation).setDuration(150).start();
                }

                break;
            }
            }

            boolean touchConsumed;
            if (smileysSelector.getY() != smileySelectorTopOffset) {
                touchConsumed = (smileysSelector.getY() != toolbarHeight);
            } else {
                touchConsumed = false;
            }

            return touchConsumed;
        }
    });
}

From source file:com.android.mail.browse.ConversationContainer.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = ev.getActionMasked();

    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
        mTouchIsDown = false;//from   w  w  w .j ava2  s  .  c om
    } else if (!mTouchIsDown
            && (action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_POINTER_DOWN)) {

        forwardFakeMotionEvent(ev, MotionEvent.ACTION_DOWN);
        if (mMissedPointerDown) {
            forwardFakeMotionEvent(ev, MotionEvent.ACTION_POINTER_DOWN);
            mMissedPointerDown = false;
        }

        mTouchIsDown = true;
    }

    final boolean webViewResult = mWebView.onTouchEvent(ev);

    //        LogUtils.v(TAG, "in Container.OnTouch. action=%d x/y=%f/%f pointers=%d",
    //                ev.getActionMasked(), ev.getX(), ev.getY(), ev.getPointerCount());
    return webViewResult;
}

From source file:com.aretha.slidemenu.SlideMenu.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    final float x = ev.getX();
    final float y = ev.getY();
    final int currentState = mCurrentState;
    if (STATE_DRAG == currentState || STATE_SCROLL == currentState) {
        return true;
    }//ww w  .j a v  a2s . c om
    switch (ev.getAction()) {
    case MotionEvent.ACTION_DOWN:
        mPressedX = mLastMotionX = x;
        mIsTapContent = isTapContent(x, y);
        return isOpen() && mIsTapContent;
    case MotionEvent.ACTION_MOVE:
        float distance = x - mPressedX;
        if (Math.abs(distance) >= mTouchSlop && mIsTapContent) {
            if (!canScroll(this, (int) distance, (int) x, (int) y)) {
                setCurrentState(STATE_DRAG);
                return true;
            }
        }
    }

    return super.onInterceptTouchEvent(ev);
}

From source file:com.jest.phone.PhoneActivity.java

@Override
public boolean onTouch(View arg0, MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN: // Start gesture
        firstFinger = new PointF(event.getX(), event.getY());
        mode = ONE_FINGER_DRAG;/*from  w  w  w .j  a v  a 2  s .  c om*/
        stopThread = true;
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_POINTER_UP:
        mode = NONE;
        break;
    case MotionEvent.ACTION_POINTER_DOWN: // second finger
        distBetweenFingers = spacing(event);
        // the distance check is done to avoid false alarms
        if (distBetweenFingers > 5f) {
            mode = TWO_FINGERS_DRAG;
        }
        break;
    case MotionEvent.ACTION_MOVE:
        if (mode == ONE_FINGER_DRAG) {
            PointF oldFirstFinger = firstFinger;
            firstFinger = new PointF(event.getX(), event.getY());
            scroll(oldFirstFinger.x - firstFinger.x);
            sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED);
            sensorHistoryPlot.redraw();

        } else if (mode == TWO_FINGERS_DRAG) {
            float oldDist = distBetweenFingers;
            distBetweenFingers = spacing(event);
            zoom(oldDist / distBetweenFingers);
            sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED);
            sensorHistoryPlot.redraw();
        }
        break;
    }
    return true;
}