Example usage for android.view MotionEvent getRawY

List of usage examples for android.view MotionEvent getRawY

Introduction

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

Prototype

public final float getRawY() 

Source Link

Document

Returns the original raw Y coordinate of this event.

Usage

From source file:com.umeng.comm.ui.widgets.RefreshLayout.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    final int action = event.getAction();

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // /*from  www .  j a v  a  2s  . com*/
        mYDown = (int) event.getRawY();
        break;

    case MotionEvent.ACTION_MOVE:
        // 
        mLastY = (int) event.getRawY();
        break;

    case MotionEvent.ACTION_UP:
        // 
        if (canLoad()) {
            loadData();
        }
        break;
    default:
        break;
    }

    return super.dispatchTouchEvent(event);
}

From source file:com.unovo.frame.uikit.refresh.SuperRefreshLayout.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    final int action = event.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // /*from  ww  w .j a  v  a 2  s. c  o m*/
        mYDown = (int) event.getRawY();
        break;

    case MotionEvent.ACTION_MOVE:
        // 
        mIsMoving = true;
        mLastY = (int) event.getRawY();
        break;
    case MotionEvent.ACTION_UP:
        mIsMoving = false;
        break;
    default:
        break;
    }
    return super.dispatchTouchEvent(event);
}

From source file:com.example.tt.pullrefresh.widget.SwipItemLayout.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
    case MotionEvent.ACTION_DOWN://???
        getParent().requestDisallowInterceptTouchEvent(true);
        startX = (int) ev.getRawX();
        startY = (int) ev.getRawY();
        break;//from   ww w  .ja va 2  s . c o  m
    case MotionEvent.ACTION_MOVE://
        int endX = (int) ev.getRawX();
        int endY = (int) ev.getRawY();
        //?
        //3.?ListView??
        if (Math.abs(endX - startX) < (Math.abs(endY - startY))) {
            getParent().requestDisallowInterceptTouchEvent(false);
        }
        break;
    }
    sheetDragHelper.processTouchEvent(ev);
    return sheetDragHelper.getCapturedView() != null || super.onTouchEvent(ev);
}

From source file:com.google.cloud.solutions.griddler.android.ui.game.GameActivity.java

/**
 * Occurs when the game surface has been touched
 *//*from   w  w  w.ja v  a2 s  .c om*/
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (this.gameState == GameStateType.PLAYING) {
        float x = event.getRawX();
        float y = event.getRawY();
        switch (event.getAction()) {
        case MotionEvent.ACTION_MOVE:
            for (IGameView gameView : this.views) {
                gameView.onTouchMove((int) x, (int) y);
            }
            break;
        case MotionEvent.ACTION_UP:
            simulate();
            break;
        }
    }
    return false;
}

From source file:com.byteshop.slidingpanel.DraggableLayout.java

private boolean isQueenTarget(MotionEvent event) {
    int[] queenLocation = new int[2];
    mDraggableQueenView.getLocationOnScreen(queenLocation);
    int upperLimit = queenLocation[1] + mDraggableQueenView.getMeasuredHeight();
    int lowerLimit = queenLocation[1];
    int y = (int) event.getRawY();
    return (y > lowerLimit && y < upperLimit);
}

From source file:com.pbi.live.VideoView.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mLivePlayer != null && mMediaController != null) {
        toggleMediaControlsVisiblity();//from   w w  w . java 2s .  co m
        Log.d(TAG, "x " + ev.getRawX() + " y " + ev.getRawY());
    }
    return false;
}

From source file:com.umeng.comm.ui.imagepicker.widgets.RefreshLayout.java

private boolean dealTouchEvent(MotionEvent event) {
    final int action = event.getAction();

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // /*from ww  w.  j  a  v a2 s.  co m*/
        mYDown = (int) event.getRawY();
        break;

    case MotionEvent.ACTION_MOVE:
        // 
        mLastY = (int) event.getRawY();
        break;

    case MotionEvent.ACTION_UP:
        // 
        if (canLoad()) {
            loadData();
        }
        if (mScrollListener != null) {
            if (isPullUp()) {
                mScrollDirection = 1;
            } else {
                mScrollDirection = 0;
            }
        }
        break;
    default:
        break;
    }
    return super.dispatchTouchEvent(event);
}

From source file:com.jungle.toolbaractivity.layout.HorizontalSwipeBackLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    if (!mSwipeBackEnable) {
        return super.onInterceptTouchEvent(event);
    }//from   w w  w.j a  v a 2  s  . c  om

    final int action = event.getActionMasked();
    final float x = event.getRawX();
    final float y = event.getRawY();
    final float horzOffset = Math.abs(x - mLastX);
    final float vertOffset = Math.abs(y - mLastY);

    if (action == MotionEvent.ACTION_DOWN) {
        mLastX = x;
        mLastY = y;
        mDownTimestamp = System.currentTimeMillis();
        mSlideState = SlideState.None;
    }

    if (mSlideState == SlideState.SkipThisRound) {
        return super.onInterceptTouchEvent(event);
    }

    if (action == MotionEvent.ACTION_MOVE && handleTouchMove(x, y, horzOffset, vertOffset)) {
        return true;
    }

    return super.onInterceptTouchEvent(event);
}

From source file:com.codingfeel.sm.views.superrecyclerview.swipe.SwipeDismissRecyclerViewTouchListener.java

private void caseMotionActionMove(MotionEvent motionEvent) {
    mVelocityTracker.addMovement(motionEvent);
    float deltaX = motionEvent.getRawX() - mDownX;
    float deltaY = motionEvent.getRawY() - mDownY;
    if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
        mSwiping = true;/*from w  w w . j ava2 s.co  m*/
        int mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
        mRecyclerView.requestDisallowInterceptTouchEvent(true);

        // Cancel ListView's touch (un-highlighting the item)
        MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
        cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (MotionEventCompat
                .getActionIndex(motionEvent) << MotionEventCompat.ACTION_POINTER_INDEX_SHIFT));
        mRecyclerView.onTouchEvent(cancelEvent);
        cancelEvent.recycle();
        if (mSwiping) {
            setTranslationX(mDownView, deltaX - mSwipingSlop);
            setAlpha(mDownView, Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth)));
        }
    }
}

From source file:com.malinskiy.superrecyclerview.swipe.SwipeDismissRecyclerViewTouchListener.java

private void caseMotionActionMove(MotionEvent motionEvent) {
    mVelocityTracker.addMovement(motionEvent);
    float deltaX = motionEvent.getRawX() - mDownX;
    float deltaY = motionEvent.getRawY() - mDownY;
    if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
        mSwiping = true;/*from www. j  a v a  2 s  .c  om*/
        mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
        mRecyclerView.requestDisallowInterceptTouchEvent(true);

        // Cancel ListView's touch (un-highlighting the item)
        MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
        cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (MotionEventCompat
                .getActionIndex(motionEvent) << MotionEventCompat.ACTION_POINTER_INDEX_SHIFT));
        mRecyclerView.onTouchEvent(cancelEvent);
        cancelEvent.recycle();
        if (mSwiping) {
            setTranslationX(mDownView, deltaX - mSwipingSlop);
            setAlpha(mDownView, Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth)));
        }
    }
}