List of usage examples for android.view MotionEvent getY
public final float getY()
From source file:org.dvbviewer.controller.ui.fragments.Remote.java
/** * Gets the gesture listener./* w w w.j a v a 2s . c om*/ * * @return the gesture listener * @author RayBa * @date 07.04.2013 */ private SimpleOnGestureListener getGestureListener() { if (gestureListener == null) { gestureListener = new SimpleOnGestureListener() { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { // SWIPE LEFT if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { return false; } flipper.setInAnimation(inFromRight); flipper.setOutAnimation(outToLeft); flipper.showPrevious(); } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { // SWIPE RIGHT if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { return false; } flipper.setInAnimation(inFromLeft); flipper.setOutAnimation(outToRight); flipper.showNext(); } else if (e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { // SWIPE UP if (Math.abs(e1.getX() - e2.getX()) > SWIPE_MAX_OFF_PATH) { } Toast.makeText(getActivity(), "Swipe up", Toast.LENGTH_SHORT).show(); } else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { // SWIPE DOWN if (Math.abs(e1.getX() - e2.getX()) > SWIPE_MAX_OFF_PATH) { } } } catch (Exception e) { e.printStackTrace(); } return true; } }; } return gestureListener; }
From source file:app.android.datetimepicker.date.SimpleMonthView.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_UP: final int day = getDayFromLocation(event.getX(), event.getY()); if (day >= 0) { onDayClick(day);/*from www. j a v a 2 s .c o m*/ } break; } return true; }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
@Override public boolean onInterceptTouchEvent(final MotionEvent me) { if (mStripVisibilityGroup.isShowingImportantNoticeStrip()) { return false; }//from www.ja v a 2 s. c o m // Detecting sliding up finger to show {@link MoreSuggestionsView}. if (!mMoreSuggestionsView.isShowingInParent()) { mLastX = (int) me.getX(); mLastY = (int) me.getY(); return mMoreSuggestionsSlidingDetector.onTouchEvent(me); } if (mMoreSuggestionsView.isInModalMode()) { return false; } final int action = me.getAction(); final int index = me.getActionIndex(); final int x = (int) me.getX(index); final int y = (int) me.getY(index); if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance || mOriginY - y >= mMoreSuggestionsModalTolerance) { // Decided to be in the sliding suggestion mode only when the touch point has been moved // upward. Further {@link MotionEvent}s will be delivered to // {@link #onTouchEvent(MotionEvent)}. mNeedsToTransformTouchEventToHoverEvent = AccessibilityUtils.getInstance().isTouchExplorationEnabled(); mIsDispatchingHoverEventToMoreSuggestions = false; return true; } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) { // Decided to be in the modal input mode. mMoreSuggestionsView.setModalMode(); } return false; }
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_UP: final CalendarDay day = getDayFromLocation(event.getX(), event.getY()); if (day != null) { onDayClick(day);//w w w . java 2s . c o m } break; } return true; }
From source file:android.support.v7.widget.FastScroller.java
@Override public void onTouchEvent(RecyclerView recyclerView, MotionEvent me) { if (mState == STATE_HIDDEN) { return;/*from ww w. ja va2 s . c om*/ } if (me.getAction() == MotionEvent.ACTION_DOWN) { boolean insideVerticalThumb = isPointInsideVerticalThumb(me.getX(), me.getY()); boolean insideHorizontalThumb = isPointInsideHorizontalThumb(me.getX(), me.getY()); if (insideVerticalThumb || insideHorizontalThumb) { if (insideHorizontalThumb) { mDragState = DRAG_X; mHorizontalDragX = (int) me.getX(); } else if (insideVerticalThumb) { mDragState = DRAG_Y; mVerticalDragY = (int) me.getY(); } setState(STATE_DRAGGING); } } else if (me.getAction() == MotionEvent.ACTION_UP && mState == STATE_DRAGGING) { mVerticalDragY = 0; mHorizontalDragX = 0; setState(STATE_VISIBLE); mDragState = DRAG_NONE; } else if (me.getAction() == MotionEvent.ACTION_MOVE && mState == STATE_DRAGGING) { show(); if (mDragState == DRAG_X) { horizontalScrollTo(me.getX()); } if (mDragState == DRAG_Y) { verticalScrollTo(me.getY()); } } }
From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { hasInteractedWithSheet = true;/*from w w w . j ava 2 s.c o m*/ if (isNestedScrolling) return false; /* prefer nested scrolling to dragging */ final int action = MotionEventCompat.getActionMasked(ev); if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { sheetDragHelper.cancel(); return false; } return isDraggableViewUnder((int) ev.getX(), (int) ev.getY()) && (sheetDragHelper.shouldInterceptTouchEvent(ev)); }
From source file:SwipeListView.java
/** * @see android.widget.ListView#onInterceptTouchEvent(android.view.MotionEvent) *//* w ww. ja v a 2s . c om*/ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); final float x = ev.getX(); final float y = ev.getY(); if (isEnabled() && touchListener.isSwipeEnabled()) { if (touchState == TOUCH_STATE_SCROLLING_X) { return touchListener.onTouch(this, ev); } switch (action) { case MotionEvent.ACTION_MOVE: checkInMoving(x, y); return touchState == TOUCH_STATE_SCROLLING_Y; case MotionEvent.ACTION_DOWN: super.onInterceptTouchEvent(ev); touchListener.onTouch(this, ev); touchState = TOUCH_STATE_REST; lastMotionX = x; lastMotionY = y; return false; case MotionEvent.ACTION_CANCEL: touchState = TOUCH_STATE_REST; break; case MotionEvent.ACTION_UP: touchListener.onTouch(this, ev); return touchState == TOUCH_STATE_SCROLLING_Y; default: break; } } return super.onInterceptTouchEvent(ev); }
From source file:activitydialogtest.pczhu.com.everytest.refresh2.SwipeListView.java
/** * @see ListView#onInterceptTouchEvent(MotionEvent) *//*from w w w . ja va 2 s. co m*/ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); final float x = ev.getX(); final float y = ev.getY(); if (isEnabled() && touchListener.isSwipeEnabled()) { if (touchState == TOUCH_STATE_SCROLLING_X) { return touchListener.onTouch(this, ev); } switch (action) { case MotionEvent.ACTION_MOVE: checkInMoving(x, y); return touchState == TOUCH_STATE_SCROLLING_Y; case MotionEvent.ACTION_DOWN: touchListener.onTouch(this, ev); touchState = TOUCH_STATE_REST; lastMotionX = x; lastMotionY = y; return false; case MotionEvent.ACTION_CANCEL: touchState = TOUCH_STATE_REST; break; case MotionEvent.ACTION_UP: touchListener.onTouch(this, ev); return touchState == TOUCH_STATE_SCROLLING_Y; default: break; } } return super.onInterceptTouchEvent(ev); }
From source file:com.asiaonline.tobaccoassistant.widget.SwipeListView.java
/** * @see android.widget.ListView#onInterceptTouchEvent(android.view.MotionEvent) *//* w w w .ja v a 2 s . co m*/ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); final float x = ev.getX(); final float y = ev.getY(); getParent().requestDisallowInterceptTouchEvent(true); if (isEnabled() && touchListener.isSwipeEnabled()) { if (touchState == TOUCH_STATE_SCROLLING_X) { return touchListener.onTouch(this, ev); } switch (action) { case MotionEvent.ACTION_MOVE: checkInMoving(x, y); return touchState == TOUCH_STATE_SCROLLING_Y; case MotionEvent.ACTION_DOWN: touchListener.onTouch(this, ev); touchState = TOUCH_STATE_REST; lastMotionX = x; lastMotionY = y; return false; case MotionEvent.ACTION_CANCEL: touchState = TOUCH_STATE_REST; break; case MotionEvent.ACTION_UP: touchListener.onTouch(this, ev); return touchState == TOUCH_STATE_SCROLLING_Y; default: break; } } return super.onInterceptTouchEvent(ev); }
From source file:CustomSwipeDismissBehavior.java
@Override public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { switch (MotionEventCompat.getActionMasked(event)) { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: // Reset the ignore flag if (mIgnoreEvents) { mIgnoreEvents = false;//from ww w.j av a 2 s . com return false; } break; default: mIgnoreEvents = !parent.isPointInChildBounds(child, (int) event.getX(), (int) event.getY()); break; } if (mIgnoreEvents) { return false; } ensureViewDragHelper(parent); return mViewDragHelper.shouldInterceptTouchEvent(event); }