MotionEvent offsetLocation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MotionEvent offsetLocation method.

This code example shows how to use the following methods:getActionIndex, getActionMasked, getRawX, obtain, offsetLocation
	} 
 
	@Override 
	public boolean onTouch(View view, MotionEvent motionEvent) {
		// offset because the view is translated during swipe 
		motionEvent.offsetLocation(mTranslationX, 0);
 
		if (mViewWidth < 2) {
			mViewWidth = mView.getWidth();
		} 
 
		switch (motionEvent.getActionMasked()) {
		case MotionEvent.ACTION_DOWN: {
			// TODO: ensure this is a finger, and set a flag 
			mDownX = motionEvent.getRawX();
			mVelocityTracker = VelocityTracker.obtain();
			mVelocityTracker.addMovement(motionEvent);
			view.onTouchEvent(motionEvent);
			return false; 
		} 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAction, getX, offsetLocation, setAction
        int buttonRange = iconWidth + ICON_SPACING;
        return (mNonIndicatorButtonCount + ((baselineX - x) / buttonRange));
    } 
 
    private void dispatchRelativeTouchEvent(View view, MotionEvent event) {
        event.offsetLocation(-view.getLeft(), -view.getTop());
        view.dispatchTouchEvent(event);
        event.offsetLocation(view.getLeft(), view.getTop());
    } 
 
    @Override 
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (!onFilterTouchEventForSecurity(event)) return false;
 
        int action = event.getAction();
        if (!isEnabled()) return false; 
 
        double x = (double) event.getX();
        int width = getWidth();
        if (width == 0) return false; // the event is sent before onMeasure()

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:offsetLocation
        c.setAction(MotionEvent.ACTION_CANCEL);
        return c;
    } 
 
    private void openPie() { 
        mDown.offsetLocation(-mOverlay.getWindowPositionX(),
                -mOverlay.getWindowPositionY());
        mOverlay.directDispatchTouch(mDown, mPie);
    } 
 
    private void cancelPie() { 
        mHandler.removeMessages(MSG_PIE);
    } 
 
    private boolean sendToPie(MotionEvent m) {
        m.offsetLocation(-mOverlay.getWindowPositionX(),
                -mOverlay.getWindowPositionY());
        return mOverlay.directDispatchTouch(m, mPie);
    } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAction, offsetLocation
		int initX; 
		int initY; 
		boolean setInitialPosition; 
		public boolean onTouch(View v, MotionEvent event) { 
//			Log.d(TAG, "state: " + mState + " x: " + event.getX() + " y: " + event.getY()); 
			int action = event.getAction(); 
			if (action == MotionEvent.ACTION_DOWN) { 
				initX = 0; 
				initY = 0; 
				if (mContent.getVisibility() == GONE) { 
					// since we may not know content dimensions we use factors here 
					if (mOrientation == VERTICAL) { 
						initY = mPosition == TOP? -1 : 1; 
					} else { 
						initX = mPosition == LEFT? -1 : 1; 
					} 
				} 
				setInitialPosition = true; 
			} else { 
				if (setInitialPosition) { 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAction, offsetLocation
                        if (mState == State.ANIMATING) { 
                                // we are animating 
                                return false; 
                        } 
//                      Log.d(TAG, "state: " + mState + " x: " + event.getX() + " y: " + event.getY()); 
                        int action = event.getAction(); 
                        if (action == MotionEvent.ACTION_DOWN) { 
                                if (mBringToFront) { 
                                        bringToFront(); 
                                } 
                                initX = 0; 
                                initY = 0; 
                                if (mContent.getVisibility() == GONE) { 
                                        // since we may not know content dimensions we use factors here 
                                        if (mOrientation == VERTICAL) { 
                                                initY = mPosition == TOP? -1 : 1; 
                                        } else { 
                                                initX = mPosition == LEFT? -1 : 1; 
                                        } 
                                } 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related MotionEvent offsetLocation Questions & Answers:

offsetLocation Method Overview
Adjust this event's location.
See Code Examples for other Android MotionEvent Methods: