Example usage for android.view MotionEvent getY

List of usage examples for android.view MotionEvent getY

Introduction

In this page you can find the example usage for android.view MotionEvent getY.

Prototype

public final float getY() 

Source Link

Document

#getY(int) for the first pointer index (may be an arbitrary pointer identifier).

Usage

From source file:Main.java

private static boolean isPointerOutside(View v, MotionEvent event) {
    float x = event.getX();
    float y = event.getY();
    if (x < 0 || x > v.getWidth() || y < 0 || y > v.getHeight())
        return true;
    return false;
}

From source file:Main.java

public static Point eventToPoint(@NonNull MotionEvent event) {
    return new Point((int) event.getX(), (int) event.getY());
}

From source file:Main.java

public static boolean isMotionOnView(View view, MotionEvent event) {
    final float x = event.getX();
    final float y = event.getY();
    if (x < view.getRight() && x > view.getLeft() && y < view.getBottom() && y > view.getTop()) {
        return true;
    }/*w  w  w  .  j  ava  2  s . co  m*/
    return false;
}

From source file:Main.java

public static float getY(MotionEvent e, int pointerIndex) {
    if (!isMultitouch) {
        return e.getY();
    }/*from  ww  w.ja v  a2 s .  com*/
    try {
        float pointerCount = (Float) motionEvent_GetY.invoke(e, new Object[] { pointerIndex });
        return pointerCount;
    } catch (Exception ex) {
        return e.getY();
    }
}

From source file:Main.java

public static float getX(MotionEvent e, int pointerIndex) {
    if (!isMultitouch) {
        return e.getY();
    }/*from   ww w .  j a  v  a 2  s  .  c o m*/
    try {
        float pointerCount = (Float) motionEvent_GetX.invoke(e, new Object[] { pointerIndex });
        return pointerCount;
    } catch (Exception ex) {
        throw new RuntimeException("Reflected multitouch method failed!", ex);
    }
}

From source file:Main.java

public static float getY(MotionEvent e, int pointerIndex) {
    if (!isMultitouch) {
        return e.getY();
    }/*w  w  w .  ja va2  s .co m*/
    try {
        float pointerCount = (Float) motionEvent_GetY.invoke(e, new Object[] { pointerIndex });
        return pointerCount;
    } catch (Exception ex) {
        throw new RuntimeException("Reflected multitouch method failed!", ex);
    }
}

From source file:Main.java

public static boolean isMotionFocusOnView(View view, MotionEvent event) {
    Rect focusBound = new Rect();
    view.getFocusedRect(focusBound);//www . ja v  a 2  s  . co m
    return focusBound.contains((int) event.getX(), (int) event.getY());
}

From source file:Main.java

public static String formatTouchPoint(MotionEvent mv) {
    if (mv == null) {
        return "";
    }/* ww w . j  ava 2s  .  com*/
    return String.format(Locale.ENGLISH, "x:%f, y:%f rawX:%f rawY: %f", mv.getX(), mv.getY(), mv.getRawX(),
            mv.getRawY());
}

From source file:Main.java

/**
 * Checks if touch event is treat as single tap
 *
 * @param context android context//  www.j  a v  a2  s  .  c  o  m
 * @param downX   axis x of touch down
 * @param downY   axis y of touch down
 * @param upEvent MotionEvent for touch up
 * @return true if it's single tap, otherwise false
 */
public static boolean isSingleTap(Context context, float downX, float downY, MotionEvent upEvent) {
    return isSingleTap(context, upEvent.getDownTime(), upEvent.getEventTime(), downX, downY, upEvent.getX(),
            upEvent.getY());
}

From source file:Main.java

public static boolean isEventInView(MotionEvent ev, View view) {
    int[] location = new int[2];
    view.getLocationInWindow(location);/*from   w w  w  . ja  v  a  2s. c  om*/
    if (ev.getX() > location[0] && ev.getX() < location[0] + view.getWidth() && ev.getY() > location[1]
            && ev.getY() < location[1] + view.getHeight()) {

        return true;
    }
    return false;
}