List of usage examples for android.view MotionEvent ACTION_CANCEL
int ACTION_CANCEL
To view the source code for android.view MotionEvent ACTION_CANCEL.
Click Source Link
From source file:Main.java
public static void dispatchCancelEvent(View view) { view.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_CANCEL, 0, 0, 0)); }
From source file:Main.java
public static String eventToString(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: return "DOWN"; case MotionEvent.ACTION_MOVE: return "MOVE"; case MotionEvent.ACTION_UP: return "UP"; case MotionEvent.ACTION_CANCEL: return "CANCEL"; case MotionEvent.ACTION_OUTSIDE: return "OUTSIDE"; case MotionEvent.ACTION_POINTER_DOWN: return "POINTER DOWN"; case MotionEvent.ACTION_POINTER_UP: return "POINTER UP"; }//from w w w.j av a 2 s.c o m return "UNKNOWN"; }
From source file:Main.java
public static String getTouchAction(int actionId) { String actionName = "Unknow:id=" + actionId; switch (actionId) { case MotionEvent.ACTION_DOWN: actionName = "ACTION_DOWN"; break;// ww w .j a v a2 s.com case MotionEvent.ACTION_MOVE: actionName = "ACTION_MOVE"; break; case MotionEvent.ACTION_UP: actionName = "ACTION_UP"; break; case MotionEvent.ACTION_CANCEL: actionName = "ACTION_CANCEL"; break; case MotionEvent.ACTION_OUTSIDE: actionName = "ACTION_OUTSIDE"; break; } return actionName; }
From source file:Main.java
/** * inject a image touch overley//from ww w . ja v a2 s. c o m * @param v * @param event */ public static boolean imageOverlay(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { // clear the overlay view.getDrawable().clearColorFilter(); view.invalidate(); break; } } return false; }
From source file:Main.java
public static void setOnTouchScaleAnimation(View targetView, final float scaleX, final float scaleY) { targetView.setOnTouchListener(new View.OnTouchListener() { @Override/* w ww . j a va2 s.c o m*/ public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: { ScaleAnimation anim = new ScaleAnimation(1.0f, scaleX, 1.0f, scaleY, v.getWidth() / 2, v.getHeight() / 2); anim.setDuration(60); anim.setFillEnabled(true); anim.setFillAfter(true); v.startAnimation(anim); break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { ScaleAnimation anim = new ScaleAnimation(scaleX, 1.0f, scaleY, 1.0f, v.getWidth() / 2, v.getHeight() / 2); anim.setDuration(100); v.startAnimation(anim); break; } } return false; } }); }
From source file:Main.java
public static String getMotionEventString(int action) { switch (action) { case (MotionEvent.ACTION_DOWN): return "action_down"; case (MotionEvent.ACTION_UP): return "action_down"; case (MotionEvent.ACTION_CANCEL): return "action_down"; case (MotionEvent.ACTION_MOVE): return "action_move"; case (MotionEvent.ACTION_OUTSIDE): return "action_outside"; case (MotionEvent.ACTION_HOVER_ENTER): return "action_hover_enter"; case (MotionEvent.ACTION_HOVER_EXIT): return "action_hover_exit"; case (MotionEvent.ACTION_HOVER_MOVE): return "action_hover_move"; case (MotionEvent.ACTION_MASK): return "action_mask"; }//from w w w . jav a 2 s.com return "unknown action event"; }
From source file:Main.java
public static void setOnTouchBackgroundEffect(View view) { view.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (!(v.getBackground() instanceof TransitionDrawable)) return false; TransitionDrawable transition = (TransitionDrawable) v.getBackground(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: transition.startTransition(500); break; case MotionEvent.ACTION_HOVER_EXIT: case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: transition.reverseTransition(500); break; }/*from w w w .j av a2 s. c o m*/ return false; } }); }
From source file:Main.java
/** * Gets the name of an action./* w ww . j av a 2s . c o m*/ * * @param action The action being performed. * @param isMotionEvent Whether or not the action is a motion event. * * @return The name of the action being performed. */ public static String getActionName(int action, boolean isMotionEvent) { switch (action) { case MotionEvent.ACTION_DOWN: return "DOWN"; case MotionEvent.ACTION_UP: return "UP"; case MotionEvent.ACTION_MOVE: return isMotionEvent ? "MOVE" : "MULTIPLE"; case MotionEvent.ACTION_CANCEL: return "CANCEL"; case MotionEvent.ACTION_OUTSIDE: return "OUTSIDE"; case MotionEvent.ACTION_POINTER_DOWN: return "POINTER_DOWN"; case MotionEvent.ACTION_POINTER_UP: return "POINTER_UP"; case MotionEvent.ACTION_HOVER_MOVE: return "HOVER_MOVE"; case MotionEvent.ACTION_SCROLL: return "SCROLL"; case MotionEvent.ACTION_HOVER_ENTER: return "HOVER_ENTER"; case MotionEvent.ACTION_HOVER_EXIT: return "HOVER_EXIT"; default: return "ACTION_" + Integer.toString(action); } }
From source file:Main.java
/** * push View ScaleAnimation// www . j a va 2 s . co m * * @param targetView TargetView * @param action MotionEventAction * @param scaleX * @param scaleY */ private static void pushScale(View targetView, int action, float scaleX, float scaleY) { if (action == MotionEvent.ACTION_DOWN) { // Touch Down ScaleAnimation anim = new ScaleAnimation(1.0f, scaleX, 1.0f, scaleY, targetView.getWidth() / 2, targetView.getHeight() / 2); anim.setDuration(DURATION); anim.setFillEnabled(true); anim.setFillAfter(true); targetView.startAnimation(anim); } else if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { // Touch Up ScaleAnimation anim = new ScaleAnimation(scaleX, 1.0f, scaleY, 1.0f, targetView.getWidth() / 2, targetView.getHeight() / 2); anim.setDuration(DURATION); anim.setFillEnabled(true); anim.setFillAfter(true); targetView.startAnimation(anim); } }
From source file:co.uk.aging.mabel.places.placepicker.cardstream.CardActionButton.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { setPressed(true);//from w w w . jav a2 s . c o m if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { animate().scaleX(0.98f).scaleY(0.98f).setDuration(100) .setInterpolator(new DecelerateInterpolator()); } else { ViewCompat.setElevation(this, 8.f); } break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { setPressed(false); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { animate().scaleX(1.f).scaleY(1.f).setDuration(50).setInterpolator(new BounceInterpolator()); } else { ViewCompat.setElevation(this, 0.f); } break; } } return super.onTouchEvent(event); }