List of usage examples for android.view MotionEvent getSize
public final float getSize()
From source file:io.github.developersofcydonia.freedtouch.FreeDTouch.java
@Override public boolean onTouch(View v, MotionEvent event) { mLastMotionEvent = event;/*w w w . ja va 2 s. c o m*/ if (!mIsPeeking) { mComputedPressureThreshold = getComputedPressureThreshold(event.getPressure(), mSensibility); mComputedSurfaceThreshold = getComputedPressureThreshold(event.getSize(), mSensibility); } else { mPeekHandler.removeCallbacks(mPeekRunnable); if (event.getPressure() >= mComputedPressureThreshold || event.getSize() >= mComputedSurfaceThreshold) { mIsPeeking = false; destroyPopup(); mListener.onPop(mPopup, v, event); } if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { mIsPeeking = false; destroyPopup(); mPeekHandler.removeCallbacks(mPeekRunnable); mListener.onCancel(mPopup, mView, event); } } return mGestureDetector.onTouchEvent(event); }
From source file:com.p3authentication.preferences.Prefs.java
@SuppressWarnings("static-access") @Override// www. j av a2 s . c o m public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int action = event.getAction(); int N = event.getHistorySize(); if (action == event.ACTION_DOWN) { calibrator.setColorFilter(Color.BLACK); for (int i = 0; i < N; i++) { calibrate(event.getHistoricalX(i), event.getHistoricalY(i), event.getHistoricalPressure(i), event.getHistoricalSize(i)); } calibrate(event.getX(), event.getY(), event.getPressure(), event.getSize()); } else if (action == event.ACTION_UP) { Float temp = Collections.max(CalList); temp = (float) Math.ceil((Double.parseDouble(Float.valueOf(temp).toString())) / 10); LargeValue = temp * 10; calibrator.setColorFilter(Color.GREEN); // Largest.setText(String.valueOf(LargeValue)); } return true; }
From source file:co.adrianblan.fastbrush.MyGLSurfaceView.java
@Override public boolean onTouchEvent(MotionEvent e) { // MotionEvent reports input details from the touch screen // and other input controls. In this case, you are only // interested in events where the touch position changed. switch (e.getAction()) { case MotionEvent.ACTION_DOWN: if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } else {//from w w w . ja va2s. c o m mVelocityTracker.clear(); } queueEvent(new Runnable() { @Override public void run() { mRenderer.touchHasStarted(); } }); // No break is intentional case MotionEvent.ACTION_MOVE: mVelocityTracker.addMovement(e); // Compute velocity in pixels per second mVelocityTracker.computeCurrentVelocity(1); final ArrayList<TouchData> touchDataList = new ArrayList<>(e.getHistorySize() + 1); Vector2 viewportPosition; Vector2 viewportVelocity = new Vector2( VelocityTrackerCompat.getXVelocity(mVelocityTracker, e.getActionIndex()), VelocityTrackerCompat.getYVelocity(mVelocityTracker, e.getActionIndex())); // Add previous touch coordinates for (int i = 0; i < e.getHistorySize(); i++) { viewportPosition = new Vector2(e.getHistoricalX(i), e.getHistoricalY(i)); touchDataList.add(new TouchData(mRenderer.viewportToWorld(viewportPosition), viewportVelocity, e.getHistoricalSize(i), e.getHistoricalPressure(i))); } // Add current touch coordinates viewportPosition = new Vector2(e.getX(), e.getY()); touchDataList.add(new TouchData(mRenderer.viewportToWorld(viewportPosition), viewportVelocity, e.getSize(), e.getPressure())); // Ensure we call switchMode() on the OpenGL thread. // queueEvent() is a method of GLSurfaceView that will do this for us. queueEvent(new Runnable() { @Override public void run() { mRenderer.addTouchData(touchDataList); } }); requestRender(); break; case MotionEvent.ACTION_UP: queueEvent(new Runnable() { @Override public void run() { mRenderer.touchHasEnded(); } }); requestRender(); break; } return true; }