List of usage examples for android.view MotionEvent ACTION_UP
int ACTION_UP
To view the source code for android.view MotionEvent ACTION_UP.
Click Source Link
From source file:Main.java
private static void dragEnd(View view, float x, float y, long downTime) { sendAction(view, MotionEvent.ACTION_UP, downTime, x, y); }
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 a v a2 s . co 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. ja v a2 s.c o m 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
public static String getActionName(int action) { String actionName = ""; switch (action) { case MotionEvent.ACTION_DOWN: actionName = "ACTION_DOWN"; break;//ww w. j a v a 2 s . c om case MotionEvent.ACTION_MOVE: actionName = "ACTION_MOVE"; break; case MotionEvent.ACTION_UP: actionName = "ACTION_UP"; break; } return actionName; }
From source file:Main.java
public static void handleTouches(ImageView button) { button.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent m) { if (m.getAction() == MotionEvent.ACTION_DOWN) { darkenImage((ImageView) v); } else if (m.getAction() == MotionEvent.ACTION_UP) { ((ImageView) v).setColorFilter(null); }// w w w . j a v a 2 s . c o m return false; } }); }
From source file:Main.java
public static void setViewTouchHightlighted(final View view) { if (view == null) { return;/*from w w w . j av a 2 s. com*/ } view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { view.setBackgroundColor(Color.rgb(1, 175, 244)); } else if (event.getAction() == MotionEvent.ACTION_UP) { view.setBackgroundColor(Color.rgb(255, 255, 255)); } return false; } }); }
From source file:Main.java
public static void setKeyboardFocus(final EditText mEditText) { (new Handler()).postDelayed(new Runnable() { public void run() { mEditText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0)); mEditText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0, 0, 0)); }// ww w . j av a2 s . c om }, 100); }
From source file:Main.java
public static void addTouchFeedback(final ImageView view) { view.setOnTouchListener(new View.OnTouchListener() { private Rect rect; @Override//from w w w. j a v a2s . c o m public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { view.setColorFilter(Color.argb(50, 0, 0, 0)); rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); } if (event.getAction() == MotionEvent.ACTION_UP) { view.setColorFilter(Color.argb(0, 0, 0, 0)); } if (event.getAction() == MotionEvent.ACTION_MOVE) { if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { view.setColorFilter(Color.argb(0, 0, 0, 0)); } } return false; } }); }
From source file:Main.java
/** * inject a image touch overley//from ww w .j a v a 2 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
/** * Performs a single touch on the center of the supplied view. * This is safe to call from the instrumentation thread and will invoke the touch * asynchronously./*from w w w. j a v a 2 s . com*/ * * @param view The view the coordinates are relative to. */ public static void simulateTouchCenterOfView(final View view) throws Throwable { view.post(new Runnable() { @Override public void run() { long eventTime = SystemClock.uptimeMillis(); float x = (float) (view.getRight() - view.getLeft()) / 2; float y = (float) (view.getBottom() - view.getTop()) / 2; view.onTouchEvent(MotionEvent.obtain(eventTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0)); view.onTouchEvent(MotionEvent.obtain(eventTime, eventTime, MotionEvent.ACTION_UP, x, y, 0)); } }); }