Java Code Examples for android.view.MotionEvent

The following are top voted examples for showing how to use android.view.MotionEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomAndroidOneSheeld   File: MutitouchKeysContainer.java   View source code 8 votes vote down vote up
private synchronized void move(MotionEvent event) {
    for (PinData item : pressedRects) {
        boolean pressed = false;
        for (int i = 0; i < (event.getPointerCount() > maxPointers ? maxPointers
                : event.getPointerCount()); i++) {
            if (item.rect
                    .contains((int) event.getX(i), (int) event.getY(i)))
                pressed = true;
        }
        if (!pressed) {
            if (item.key != null && item.key.eventListener != null)
                item.key.eventListener.onReleased(item.key);
            pressedRects.remove(item);
        }
    }
    for (int i = 0; i < (event.getPointerCount() > maxPointers ? maxPointers
            : event.getPointerCount()); i++) {
        down((int) event.getX(i), (int) event.getY(i));
    }
}
 
Example 2
Project: android-project-gallery   File: ViewPagerCompat.java   View source code 7 votes vote down vote up
/**
 * Start a fake drag of the pager.
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view, while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 *
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress, this method will return false.
 *
 * @return true if the fake drag began successfully, false if it could not be started.
 *
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    mInitialMotionX = mLastMotionX = 0;
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    } else {
        mVelocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
    mVelocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
 
Example 3
Project: mupdf-android-viewer-old   File: MuPDFReaderView.java   View source code 6 votes vote down vote up
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
		float distanceY) {
	MuPDFView pageView = (MuPDFView)getDisplayedView();
	switch (mMode) {
	case Viewing:
		if (!tapDisabled)
			onDocMotion();

		return super.onScroll(e1, e2, distanceX, distanceY);
	case Selecting:
		if (pageView != null)
			pageView.selectText(e1.getX(), e1.getY(), e2.getX(), e2.getY());
		return true;
	default:
		return true;
	}
}
 
Example 4
Project: TriangularCustomView   File: IndicatorView.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    int eventAction = event.getAction();
    int x = (int)event.getX();
    int y = (int)event.getY();
    switch (eventAction) {
        case MotionEvent.ACTION_DOWN:
            midpt.x = ((x*noOfTabs)/getWidth())*((getWidth()/noOfTabs)) + ((getWidth()/noOfTabs)/2);
            triangle.reset();
            break;
        case MotionEvent.ACTION_UP:
            break;
        case MotionEvent.ACTION_MOVE:
            break;
    }
    invalidate();
    return true;
}
 
Example 5
Project: WeiXinRecordedDemo   File: TuyaView.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    if(isDrawMode) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                touchMode = true;
                touchDown(event);
                if(onTouchListener != null) onTouchListener.onDown();
                break;
            case MotionEvent.ACTION_MOVE:
                touchMove(event);
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                touchMode = false;
                savePathList.add(new Path(mPath));
                paintList.add(new Paint(mPaint));
                if(onTouchListener != null) onTouchListener.onUp();
                if(onLineChangeListener != null) onLineChangeListener.onDrawLine(savePathList.size());
                break;
        }
        invalidate();
    }
    return isDrawMode;
}
 
Example 6
Project: DailyStudy   File: DefaultOnDoubleTapListener.java   View source code 6 votes vote down vote up
@Override
public boolean onDoubleTap(MotionEvent ev) {
    if (photoViewAttacher == null)
        return false;

    try {
        float scale = photoViewAttacher.getScale();
        float x = ev.getX();
        float y = ev.getY();

        if (scale < photoViewAttacher.getMediumScale()) {
            photoViewAttacher.setScale(photoViewAttacher.getMediumScale(), x, y, true);
        } else if (scale >= photoViewAttacher.getMediumScale() && scale < photoViewAttacher.getMaximumScale()) {
            photoViewAttacher.setScale(photoViewAttacher.getMaximumScale(), x, y, true);
        } else {
            photoViewAttacher.setScale(photoViewAttacher.getMinimumScale(), x, y, true);
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        // Can sometimes happen when getX() and getY() is called
    }

    return true;
}
 
Example 7
Project: GitHub   File: BaseViewPager.java   View source code 6 votes vote down vote up
/**
 * Start a fake drag of the pager.
 * <p/>
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view, while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 * <p/>
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress, this method will return false.
 *
 * @return true if the fake drag began successfully, false if it could not be started.
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    if (isHorizontalDirection()) {
        mInitialMotionX = mLastMotionX = 0;
    } else if (isVerticalDirection()) {
        mInitialMotionY = mLastMotionY = 0;
    }
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    } else {
        mVelocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
    mVelocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
 
Example 8
Project: bannerview   File: BannerView.java   View source code 6 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    int action = ev.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mIsResumed = false;
        update();
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        mIsResumed = true;
        update();
        break;
    }
    return super.dispatchTouchEvent(ev);
}
 
Example 9
Project: AndroidOpen   File: SwipeToRefreshLayout.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);
    if (isBackToStart && action == MotionEvent.ACTION_DOWN) isBackToStart = false;
    switch (mType) {
        case BOTTOM:
            if (!isEnabled() || isBackToStart || canChildScrollDown() || isRefreshing) {
                return false;
            }
            break;
        case TOP:
        default:
            if (!isEnabled() || isBackToStart || canChildScrollUp() || isRefreshing) {
                return false;
            }
            break;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            isReady = false;
            break;
        case MotionEvent.ACTION_MOVE:
            if (TouchActionMove(ev)) return false;
            break;
        case MotionEventCompat.ACTION_POINTER_DOWN:
            final int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL: {
            return TouchActionCancel(ev);
        }
    }
    return true;
}
 
Example 10
Project: LiuAGeAndroid   File: CustomViewAbove.java   View source code 6 votes vote down vote up
private boolean isInIgnoredView(MotionEvent ev) {
	Rect rect = new Rect();
	for (View v : mIgnoredViews) {
		v.getHitRect(rect);
		if (rect.contains((int)ev.getX(), (int)ev.getY())) return true;
	}
	return false;
}
 
Example 11
Project: sealtalk-android-master   File: HorizontalListView.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    // Detect when the user lifts their finger off the screen after a touch
    if (event.getAction() == MotionEvent.ACTION_UP) {
        // If not flinging then we are idle now. The user just finished a finger scroll.
        if (mFlingTracker == null || mFlingTracker.isFinished()) {
            setCurrentScrollState(OnScrollStateChangedListener.ScrollState.SCROLL_STATE_IDLE);
        }

        // Allow the user to interact with parent views
        requestParentListViewToNotInterceptTouchEvents(false);

        releaseEdgeGlow();
    } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
        unpressTouchedChild();
        releaseEdgeGlow();

        // Allow the user to interact with parent views
        requestParentListViewToNotInterceptTouchEvents(false);
    }

    return super.onTouchEvent(event);
}
 
Example 12
Project: Mp3Player   File: VerticalSeekBar.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled()) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            Log.d("Action down","Progress ="+progress);
        case MotionEvent.ACTION_MOVE:
            Log.d("Action move","Progress ="+progress);
        case MotionEvent.ACTION_UP:
            if(event.getY()<=getHeight() && event.getY()>=0) {
                progress = getMax() - (int) (getMax() * event.getY() / getHeight());
                Log.d("Action up", "Progress =" + progress);
                Log.d("GetMax Return", " " + getMax() + " getHeight " + getHeight() + " getY " + event.getY());
                this.setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
            }
            onSizeChanged(getWidth(), getHeight(), 0, 0);
            break;

        case MotionEvent.ACTION_CANCEL:
            break;
    }
    return true;
}
 
Example 13
Project: LaunchEnr   File: Workspace.java   View source code 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    switch (ev.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        mXDown = ev.getX();
        mYDown = ev.getY();
        mTouchDownTime = System.currentTimeMillis();
        break;
    case MotionEvent.ACTION_POINTER_UP:
    case MotionEvent.ACTION_UP:
        if (mTouchState == TOUCH_STATE_REST) {
            final CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
            if (currentPage != null) {
                onWallpaperTap(ev);
            }
        }
    }
    return super.onInterceptTouchEvent(ev);
}
 
Example 14
Project: PlusGram   File: HsvColorValueView.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	if(event.getAction() == MotionEvent.ACTION_DOWN)
	{
		down = true;
		return true;
	}
	if(event.getAction() == MotionEvent.ACTION_UP)
	{
		down = false;
		setSelectorPosition((int)event.getX() - getBackgroundOffset(), (int)event.getY() - getBackgroundOffset(), true);
		return true;
	}
	if(event.getAction() == MotionEvent.ACTION_MOVE && down)
	{
		setSelectorPosition((int)event.getX() - getBackgroundOffset(), (int)event.getY() - getBackgroundOffset(), false);
		return true;
	}
	return super.onTouchEvent(event);
}
 
Example 15
Project: Auto.js   File: PaintView.java   View source code 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getY();
    float y = event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            onTouchDown(x, y);
            return true;
        case MotionEvent.ACTION_MOVE:
            onTouchMove(x, y);
            return true;
        case MotionEvent.ACTION_UP:
            onTouchUp(x, y);
            return true;
    }
    return super.onTouchEvent(event);
}
 
Example 16
Project: SmartRecyclerView   File: RecyclerItemClickListener.java   View source code 5 votes vote down vote up
public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
    mListener = listener;
    mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }
    });
}
 
Example 17
Project: ucar-weex-core   File: WXFrameLayout.java   View source code 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean result = super.onTouchEvent(event);
  if (wxGesture != null) {
    result |= wxGesture.onTouch(this, event);
  }
  return result;
}
 
Example 18
Project: GitHub   File: VersionedGestureDetector.java   View source code 5 votes vote down vote up
@Override
float getActiveX(MotionEvent ev) {
	try {
		return ev.getX(mActivePointerIndex);
	} catch (Exception e) {
		return ev.getX();
	}
}
 
Example 19
Project: Tribe   File: PhotoViewAttacher.java   View source code 5 votes vote down vote up
public final boolean onSingleTapConfirmed(MotionEvent e) {
	ImageView imageView = getImageView();

	if (null != imageView) {
		if (null != mPhotoTapListener) {
			final RectF displayRect = getDisplayRect();

			if (null != displayRect) {
				final float x = e.getX(), y = e.getY();

				// Check to see if the user tapped on the photo
				if (displayRect.contains(x, y)) {

					float xResult = (x - displayRect.left) / displayRect.width();
					float yResult = (y - displayRect.top) / displayRect.height();

					mPhotoTapListener.onPhotoTap(imageView, xResult, yResult);
					return true;
				}
			}
		}
		if (null != mViewTapListener) {
			mViewTapListener.onViewTap(imageView, e.getX(), e.getY());
		}
	}

	return false;
}
 
Example 20
Project: airgram   File: NumberPicker.java   View source code 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    final int action = event.getActionMasked();
    switch (action) {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            removeAllCallbacks();
            break;
    }
    return super.dispatchTouchEvent(event);
}
 
Example 21
Project: GitHub   File: Banner.java   View source code 5 votes vote down vote up
@Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
//        Log.i(tag, ev.getAction() + "--" + isAutoPlay);
        if (isAutoPlay) {
            int action = ev.getAction();
            if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL
                    || action == MotionEvent.ACTION_OUTSIDE) {
                startAutoPlay();
            } else if (action == MotionEvent.ACTION_DOWN) {
                stopAutoPlay();
            }
        }
        return super.dispatchTouchEvent(ev);
    }
 
Example 22
Project: TableView   File: CellRecyclerViewItemClickListener.java   View source code 5 votes vote down vote up
@Override
protected boolean clickAction(RecyclerView view, MotionEvent e) {
    // Get interacted view from x,y coordinate.
    View childView = view.findChildViewUnder(e.getX(), e.getY());

    if (childView != null && m_jGestureDetector.onTouchEvent(e)) {
        // Find the view holder
        AbstractViewHolder holder = (AbstractViewHolder) m_jRecyclerView.getChildViewHolder
                (childView);

        // Get y position from adapter
        CellRowRecyclerViewAdapter adapter = (CellRowRecyclerViewAdapter) m_jRecyclerView
                .getAdapter();

        int nXPosition = holder.getAdapterPosition();
        int nYPosition = adapter.getYPosition();

        // Control to ignore selection color
        if (!m_iTableView.isIgnoreSelectionColors()) {
            m_iSelectionHandler.setSelectedCellPositions(holder, nXPosition, nYPosition);
        }

        if (getTableViewListener() != null) {
            // Call ITableView listener for item click
            getTableViewListener().onCellClicked(holder, nXPosition, nYPosition);
        }

        return true;
    }
    return false;
}
 
Example 23
Project: android-study   File: XfermodeView.java   View source code 5 votes vote down vote up
@Override public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      mPath.reset();
      mPath.moveTo(event.getX(), event.getY());
      break;
    case MotionEvent.ACTION_MOVE:
      mPath.lineTo(event.getX(), event.getY());
      break;
  }
  mCanvas.drawPath(mPath, mPaint);
  invalidate();
  return true;
}
 
Example 24
Project: Android-Code-Demos   File: OnRecyclerItemClickListener.java   View source code 5 votes vote down vote up
@Override
public boolean onSingleTapUp(MotionEvent e) {
    View child = mRecyclerView.findChildViewUnder(e.getX(), e.getY());
    if (null != child) {
        RecyclerView.ViewHolder vh = mRecyclerView.getChildViewHolder(child);
        onItemClick(vh);
    }
    return true;
}
 
Example 25
Project: CXJPadProject   File: OrcVinActivity.java   View source code 5 votes vote down vote up
public boolean onTouchEvent(MotionEvent event) {
    // int Action = event.getAction();
    //  float X = event.getX();
    //   float Y = event.getY();
    remind.setVisibility(View.INVISIBLE);
    vin_result.setVisibility(View.INVISIBLE);
    showbitmap.setVisibility(View.INVISIBLE);
    return true;
}
 
Example 26
Project: GitHub   File: ZoomableDraweeView.java   View source code 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
  int a = event.getActionMasked();
  FLog.v(getLogTag(), "onTouchEvent: %d, view %x, received", a, this.hashCode());
  if (mTapGestureDetector.onTouchEvent(event)) {
    FLog.v(
        getLogTag(),
        "onTouchEvent: %d, view %x, handled by tap gesture detector",
        a,
        this.hashCode());
    return true;
  }

  if (mZoomableController.onTouchEvent(event)) {
    FLog.v(
        getLogTag(),
        "onTouchEvent: %d, view %x, handled by zoomable controller",
        a,
        this.hashCode());
    if (!mAllowTouchInterceptionWhileZoomed && !mZoomableController.isIdentity()) {
      getParent().requestDisallowInterceptTouchEvent(true);
    }
    return true;
  }
  if (super.onTouchEvent(event)) {
    FLog.v(getLogTag(), "onTouchEvent: %d, view %x, handled by the super", a, this.hashCode());
    return true;
  }
  // None of our components reported that they handled the touch event. Upon returning false
  // from this method, our parent won't send us any more events for this gesture. Unfortunately,
  // some components may have started a delayed action, such as a long-press timer, and since we
  // won't receive an ACTION_UP that would cancel that timer, a false event may be triggered.
  // To prevent that we explicitly send one last cancel event when returning false.
  MotionEvent cancelEvent = MotionEvent.obtain(event);
  cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
  mTapGestureDetector.onTouchEvent(cancelEvent);
  mZoomableController.onTouchEvent(cancelEvent);
  cancelEvent.recycle();
  return false;
}
 
Example 27
Project: android-open-source-project-analysis   File: WindowActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_window);

    findViewById(R.id.btn_add_view).setOnClickListener(this);
    findViewById(R.id.btn_remove_view).setOnClickListener(this);

    windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT
            , WindowManager.LayoutParams.WRAP_CONTENT, 0, 0, PixelFormat.TRANSLUCENT);
    layoutParams.x = 100;
    layoutParams.y = 100;
    layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION;

    button = new Button(this);
    button.setText("Button");

    button.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_MOVE:
                    if (windowManager != null) {
                        layoutParams.x = (int) event.getRawX();
                        layoutParams.y = (int) event.getRawY();
                        windowManager.updateViewLayout(button, layoutParams);
                    }
                    break;
            }

            return false;
        }
    });
}
 
Example 28
Project: CameraButton   File: CameraButton.java   View source code 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    final int action = event.getActionMasked();
    switch (action) {
        case MotionEvent.ACTION_DOWN: {
            if (isEnabled() && isTouched(event)) {
                postExpandingMessageIfNeeded();
                makePaintColorsHovered(true);
                invalidate();
                dispatchStateChange(PRESSED);
                return true;
            }
        }

        case MotionEvent.ACTION_UP: {
            if (mCurrentState == START_EXPANDING || mCurrentState == EXPANDED) {
                if (mExpandAnimator != null) {
                    mExpandAnimator.cancel();
                }
                mCollapseAnimator = createCollapsingAnimator();
                mCollapseAnimator.start();

                makePaintColorsHovered(false);
                invalidate();
                return true;
            } else if (mCurrentState == PRESSED) {
                removeCallbacks(mExpandMessage);
                dispatchStateChange(DEFAULT);

                makePaintColorsHovered(false);
                invalidate();
                return true;
            }
        }
    }
    return false;
}
 
Example 29
Project: social-app-android   File: TouchImageView.java   View source code 5 votes vote down vote up
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    if (fling != null) {
        //
        // If a previous fling is still active, it should be cancelled so that two flings
        // are not run simultaenously.
        //
        fling.cancelFling();
    }
    fling = new Fling((int) velocityX, (int) velocityY);
    compatPostOnAnimation(fling);
    return super.onFling(e1, e2, velocityX, velocityY);
}
 
Example 30
Project: boohee_v5.6   File: ListPopupWindow.java   View source code 5 votes vote down vote up
private boolean onTouchObserved(MotionEvent srcEvent) {
    View src = this.mSrc;
    if (!src.isEnabled()) {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(srcEvent)) {
        case 0:
            this.mActivePointerId = srcEvent.getPointerId(0);
            this.mWasLongPress = false;
            if (this.mDisallowIntercept == null) {
                this.mDisallowIntercept = new DisallowIntercept();
            }
            src.postDelayed(this.mDisallowIntercept, (long) this.mTapTimeout);
            if (this.mTriggerLongPress == null) {
                this.mTriggerLongPress = new TriggerLongPress();
            }
            src.postDelayed(this.mTriggerLongPress, (long) this.mLongPressTimeout);
            return false;
        case 1:
        case 3:
            clearCallbacks();
            return false;
        case 2:
            int activePointerIndex = srcEvent.findPointerIndex(this.mActivePointerId);
            if (activePointerIndex < 0 || pointInView(src, srcEvent.getX(activePointerIndex), srcEvent.getY(activePointerIndex), this.mScaledTouchSlop)) {
                return false;
            }
            clearCallbacks();
            src.getParent().requestDisallowInterceptTouchEvent(true);
            return true;
        default:
            return false;
    }
}
 
Example 31
Project: HexagonRecyclerView   File: PolygonItemView.java   View source code 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (!isEventInPath(event)) {
            return false;
        }
    }
    return super.dispatchTouchEvent(event);
}
 
Example 32
Project: boohee_v5.6   File: DrawerLayout.java   View source code 5 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent ev) {
    boolean interceptForDrag = this.mLeftDragger.shouldInterceptTouchEvent(ev) | this.mRightDragger.shouldInterceptTouchEvent(ev);
    boolean interceptForTap = false;
    switch (MotionEventCompat.getActionMasked(ev)) {
        case 0:
            float x = ev.getX();
            float y = ev.getY();
            this.mInitialMotionX = x;
            this.mInitialMotionY = y;
            if (this.mScrimOpacity > 0.0f) {
                View child = this.mLeftDragger.findTopChildUnder((int) x, (int) y);
                if (child != null && isContentView(child)) {
                    interceptForTap = true;
                }
            }
            this.mDisallowInterceptRequested = false;
            this.mChildrenCanceledTouch = false;
            break;
        case 1:
        case 3:
            closeDrawers(true);
            this.mDisallowInterceptRequested = false;
            this.mChildrenCanceledTouch = false;
            break;
        case 2:
            if (this.mLeftDragger.checkTouchSlop(3)) {
                this.mLeftCallback.removeCallbacks();
                this.mRightCallback.removeCallbacks();
                break;
            }
            break;
    }
    if (interceptForDrag || interceptForTap || hasPeekingDrawer() || this.mChildrenCanceledTouch) {
        return true;
    }
    return false;
}
 
Example 33
Project: Mybilibili   File: ConvenientBanner.java   View source code 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

    if (ev.getAction() == MotionEvent.ACTION_UP) {
        // 开始翻页
        if (canTurn)startTurning(autoTurningTime);
    } else if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        // 停止翻页
        if (canTurn)stopTurning();
    }
    return super.dispatchTouchEvent(ev);
}
 
Example 34
Project: weex-uikit   File: WXGestureTest.java   View source code 5 votes vote down vote up
@Test
public void testOnTouch() throws Exception {
  MotionEvent event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_DOWN,0,0,0);
  mGesture.onTouch(component.getHostView(),event);

  event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_MOVE,0,0,0);
  mGesture.onTouch(component.getHostView(),event);

  event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_UP,0,0,0);
  mGesture.onTouch(component.getHostView(),event);

  event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_POINTER_UP,0,0,0);
  mGesture.onTouch(component.getHostView(),event);

  event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_CANCEL,0,0,0);
  mGesture.onTouch(component.getHostView(),event);
}
 
Example 35
Project: RLibrary   File: StickLayout2.java   View source code 5 votes vote down vote up
private void onTouchDown(MotionEvent ev) {
    onTouchUp();

    downY = ev.getY() + 0.5f;
    lastX = downX = ev.getX() + 0.5f;
    mStartScrollY = getScrollY();

    mOverScroller.abortAnimation();

    isFling = false;

    if (isFloat()) {
        if (mFloatView.getMeasuredHeight() + floatTopOffset > downY) {
            inTopTouch = true;
        } else {
            inTopTouch = false;
        }
    } else {
        if (topHeight - mStartScrollY > downY) {
            inTopTouch = true;
        } else {
            inTopTouch = false;
        }
    }
    isFirst = true;

    initScrollTarget();
}
 
Example 36
Project: boohee_v5.6   File: TopicFragment.java   View source code 5 votes vote down vote up
public boolean isViewBeingDragged(MotionEvent event) {
    if (this.mPullRefreshListView == null) {
        return false;
    }
    return this.mAbsListViewDelegate.isViewBeingDragged(event, (AbsListView) this
            .mPullRefreshListView.getRefreshableView());
}
 
Example 37
Project: ButterflyButton   File: ButterdomButton.java   View source code 5 votes vote down vote up
/**
 * To click an option.
 *
 * @param event
 * @return
 */
@Override
public boolean onTouchEvent(MotionEvent event) {
    ButterflyOption selectedOption = model.getSelectedOption();

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            for (ButterflyOption option : model.getOptions()) {
                if (option != null) {
                    if (event.getX() >= option.getOffsetX() && event.getX() <= option.getPostsetX()
                            && event.getY() >= option.getOffsetY() && event.getY() <= option.getPostsetY()) {
                        isOnClick = true;
                        model.setSelectedOption(option);
                    }
                }
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            if (isOnClick && selectedOption != null) {
                isOnClick = false;
                if (listener != null) listener.onOptionSelected(selectedOption.getPosition(), selectedOption.getIcon());
                if (model.isCloseOnSelect()) closeBubble();
                else invalidate();
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (isOnClick && (Math.abs(selectedOption.getX() - event.getX()) > CLICK_ACTION_THRESHHOLD)
                    || Math.abs(selectedOption.getY() - event.getY()) > CLICK_ACTION_THRESHHOLD) {
                isOnClick = false;
                model.setSelectedOption(null);
            }
            break;
    }
    return true;
}
 
Example 38
Project: rongyunDemo   File: ReadReceiptViewPager.java   View source code 5 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
    if (unscrollable)
        return false;
    else
        return super.onInterceptTouchEvent(arg0);
}
 
Example 39
Project: NeiHanDuanZiTV   File: CustomGestureDetector.java   View source code 5 votes vote down vote up
public boolean onTouchEvent(MotionEvent ev) {
    try {
        mDetector.onTouchEvent(ev);
        return processTouchEvent(ev);
    } catch (IllegalArgumentException e) {
        // Fix for support lib bug, happening when onDestroy is called
        return true;
    }
}
 
Example 40
Project: CCDownload   File: ADMediaPlayActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onDoubleTap(MotionEvent e) {
	if (lockView.isSelected()) {
		return true;
	}
	if (!isDisplay) {
		setLayoutVisibility(View.VISIBLE, true);
	}
	changePlayStatus();
	return super.onDoubleTap(e);
}