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:io.lqd.sdk.visual.SlideUp.java

private void animateDown(MotionEvent event) {
    mCurrentY = (int) (event.getRawY() + mDy);
    if (mCurrentY > 0) {
        setTransparency(1 - (float) mCurrentY * 1 / height); //root equation: 0.5F + (float) mCurrentY * 1 / (2 * height)

        if (mNewSDK)
            animateNew(mCurrentY, 0);//from  w  w w.jav a  2  s  .  c om
        else {
            animateOld(mCurrentX, -mCurrentY, -1, -1, false);
        }
    }
}

From source file:io.lqd.sdk.visual.SlideUp.java

@Override
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        mDy = mCurrentY - event.getRawY();
    }//  ww  w  .  j  ava 2  s  .  c  om
    if (isSlidingDown(event))
        animateDown(event);
    if (isCancelingSlideDown(event)) {
        if (mCurrentY * 1.5F >= height / 2)
            dismiss();
        else
            resetPosition();
    }
    return false;
}

From source file:com.focosee.qingshow.widget.MVerticalViewPager.java

public boolean onTouchEvent(MotionEvent event) {
    super.onTouchEvent(event);

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }//  w w  w .  j a v  a  2  s .c o m
    mVelocityTracker.addMovement(event);

    float currentY = event.getRawY();
    switch (event.getAction() & MotionEventCompat.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        mLastY = currentY;
        mMoved = false;
        break;
    case MotionEvent.ACTION_MOVE:
        mMoved = true;
        break;
    case MotionEvent.ACTION_UP:
        if (mMoved) {
            mVelocityTracker.computeCurrentVelocity(1000);
            int velocity = (int) mVelocityTracker.getYVelocity();
            float moveDistance = currentY - mLastY;
            int nextPage = mCurrentPage;
            if (moveDistance < 0 && Math.abs(moveDistance) >= SCROLL_PERCENTAGE * mSinglePageHeight
                    || velocity < 0 && Math.abs(velocity) > MIN_FLING_VELOCITY) {
                ++nextPage;
            } else if (moveDistance > 0 && Math.abs(moveDistance) >= SCROLL_PERCENTAGE * mSinglePageHeight
                    || velocity > 0 && Math.abs(velocity) > MIN_FLING_VELOCITY) {
                --nextPage;
            }
            setCurrentItem(nextPage);
        }
        break;
    }
    return true;
}

From source file:com.yamin.kk.fragment.AudioMiniPlayer.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.audio_player_mini, container, false);

    // Initialize the children
    mCover = (ImageView) v.findViewById(R.id.cover);
    mTitle = (TextView) v.findViewById(R.id.title);
    mArtist = (TextView) v.findViewById(R.id.artist);
    mPlayPause = (ImageButton) v.findViewById(R.id.play_pause);
    mForward = (ImageButton) v.findViewById(R.id.forward);
    mBackward = (ImageButton) v.findViewById(R.id.backward);
    mPlayPause.setOnClickListener(onMediaControlClickListener);
    mForward.setOnClickListener(onMediaControlClickListener);
    mBackward.setOnClickListener(onMediaControlClickListener);
    mProgressBar = (ProgressBar) v.findViewById(R.id.timeline);

    final LinearLayout root = (LinearLayout) v.findViewById(R.id.root_node);

    root.setOnTouchListener(new View.OnTouchListener() {
        @Override/*from  w  w w.  j  a  v a2 s. co m*/
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mTouchX = event.getRawX();
                mTouchY = event.getRawY();
                break;
            case MotionEvent.ACTION_UP:
                if (mTouchY - event.getRawY() > root.getHeight()) {
                    Toast.makeText(AudioMiniPlayer.this.getActivity(), "AudioMiniPlayer swipe up",
                            Toast.LENGTH_SHORT).show();
                    return true;
                } else if (Math.abs(mTouchY - event.getRawY()) < 5 && Math.abs(mTouchX - event.getRawX()) < 5) {
                    // effectively a click
                    AudioPlayerFragment.start(getActivity());
                    return true;
                } else
                    return false;
            }
            return true;
        }
    });

    registerForContextMenu(v);
    return v;
}

From source file:io.github.hidroh.materialistic.widget.NavFloatingActionButton.java

@Synthetic
void startDrag(float startX, float startY) {
    mVibrator.vibrate(VIBRATE_DURATION_MS * 2);
    Toast.makeText(getContext(), R.string.hint_drag, Toast.LENGTH_SHORT).show();
    //noinspection Convert2Lambda
    super.setOnTouchListener(new OnTouchListener() {
        @SuppressLint("ClickableViewAccessibility")
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override/*from   w w  w .  jav a2 s  .  c o  m*/
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_MOVE:
                view.setX(motionEvent.getRawX() - startX); // TODO compensate shift
                view.setY(motionEvent.getRawY() - startY);
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                bindNavigationPad();
                break;
            default:
                return false;
            }
            return true;
        }
    });
}

From source file:com.tmall.wireless.tangram.view.LinearScrollView.java

@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;//from  ww w.j ava2s. co  m
        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;
    }

    return false;
}

From source file:com.whiterabbit.dragqueen.OuterLayout.java

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

From source file:com.kerkr.edu.recycleView.SwipeToDismissTouchListener.java

private boolean down(MotionEvent motionEvent) {
    if (mPaused)//  ww  w  . j a v  a 2s  . c om
        return false;

    mDownX = motionEvent.getRawX();
    mDownY = motionEvent.getRawY();
    mSwipeView = mRecyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
    if (mSwipeView == null)
        return false;
    int pos = mRecyclerView.getChildPosition(mSwipeView);
    mAllowedSwipeDirection = mCallbacks.canDismiss(pos);
    if (mAllowedSwipeDirection != SwipeDirection.NONE) {

        mVelocityTracker = VelocityTracker.obtain();
        mVelocityTracker.addMovement(motionEvent);
        return false;
    }
    resetMotion();
    return false;
}

From source file:com.tjych.swip.vertical_t.VerticalViewPager.java

public boolean onTouchEvent(MotionEvent event) {
    super.onTouchEvent(event);

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }/* www  .ja v  a  2 s. co m*/
    mVelocityTracker.addMovement(event);

    float currentY = event.getRawY();
    float currentX = event.getRawX();
    switch (event.getAction() & MotionEventCompat.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        mLastY = currentY;
        mLastX = currentX;
        mMoved = false;
        return false;
    case MotionEvent.ACTION_MOVE:
        float x = event.getRawX() - mLastX;
        float y = event.getRawY() - mLastY;

        System.out.println(x + " : " + y);

        if (Math.abs(x) > Math.abs(y)) {
            // getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        } else {
            mMoved = true;
            return true;
        }

    case MotionEvent.ACTION_UP:
        x = event.getRawX() - mLastX;
        y = event.getRawY() - mLastY;
        System.out.println(x + " : " + y);
        if (Math.abs(x) > Math.abs(y)) {
            // getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
        if (mMoved) {
            mVelocityTracker.computeCurrentVelocity(1000);
            int velocity = (int) mVelocityTracker.getYVelocity();
            float moveDistance = currentY - mLastY;
            int nextPage = mCurrentPage;
            if (moveDistance < 0 && Math.abs(moveDistance) >= SCROLL_PERCENTAGE * mSinglePageHeight
                    || velocity < 0 && Math.abs(velocity) > MIN_FLING_VELOCITY) {
                ++nextPage;
            } else if (moveDistance > 0 && Math.abs(moveDistance) >= SCROLL_PERCENTAGE * mSinglePageHeight
                    || velocity > 0 && Math.abs(velocity) > MIN_FLING_VELOCITY) {
                --nextPage;
            }
            setCurrentItem(nextPage);
        }
        return true;
    }
    return true;
}

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

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

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // /*from  w  w  w  .ja v  a2s.  c o  m*/
        mYDown = (int) event.getRawY();
        break;

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

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

    return super.dispatchTouchEvent(event);
}