Example usage for android.view MotionEvent getRawY

List of usage examples for android.view MotionEvent getRawY

Introduction

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

Prototype

public final float getRawY() 

Source Link

Document

Returns the original raw Y coordinate of this event.

Usage

From source file:Main.java

public static boolean isTouchInView(MotionEvent ev, View v) {
    int[] vLoc = new int[2];
    v.getLocationOnScreen(vLoc);//from   w  w  w  .j  a va  2 s.  co m
    float motionX = ev.getRawX();
    float motionY = ev.getRawY();
    return motionX >= vLoc[0] && motionX <= (vLoc[0] + v.getWidth()) && motionY >= vLoc[1]
            && motionY <= (vLoc[1] + v.getHeight());
}

From source file:Main.java

public static String formatTouchPoint(MotionEvent mv) {
    if (mv == null) {
        return "";
    }/* w  ww . j  av a 2 s.co  m*/
    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

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static void focusOnTouch(Camera camera, MotionEvent event) {
    Rect focusRect = calculateTapArea(camera, event.getRawX(), event.getRawY(), 1f);
    Rect meteringRect = calculateTapArea(camera, event.getRawX(), event.getRawY(), 1.5f);

    Camera.Parameters parameters = camera.getParameters();
    parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    int version = Build.VERSION.SDK_INT;
    if (version > Build.VERSION_CODES.ICE_CREAM_SANDWICH && parameters.getMaxNumFocusAreas() > 0) {
        List<Camera.Area> focusAreas = new ArrayList<Camera.Area>();
        focusAreas.add(new Camera.Area(focusRect, 1000));

        parameters.setFocusAreas(focusAreas);
    }/*from   w w  w.ja  va 2  s  .  c om*/

    if (version > Build.VERSION_CODES.ICE_CREAM_SANDWICH && parameters.getMaxNumMeteringAreas() > 0) {
        List<Camera.Area> meteringAreas = new ArrayList<Camera.Area>();
        meteringAreas.add(new Camera.Area(meteringRect, 1000));

        parameters.setMeteringAreas(meteringAreas);
    }

    camera.setParameters(parameters);
}

From source file:Main.java

public static boolean isInRangeOfView(View view, MotionEvent ev) {
    int[] location = new int[2];
    view.getLocationOnScreen(location);/*from   www  .j  ava2 s .  c  om*/
    int x = location[0];
    int y = location[1];
    if (ev.getRawX() < x || ev.getRawX() > (x + view.getWidth()) || ev.getRawY() < y
            || ev.getRawY() > (y + view.getHeight())) {
        return false;
    }
    return true;
}

From source file:net.nym.napply.library.behavior.HeadOffsetBehavior.java

public static boolean inRangeOfView(View view, MotionEvent ev) {
    int[] location = new int[2];
    view.getLocationOnScreen(location);/* w w  w  . ja  v a2 s .c  om*/
    int x = location[0];
    int y = location[1];
    if (ev.getRawX() < x || ev.getRawX() > (x + view.getWidth()) || ev.getRawY() < y
            || ev.getRawY() > (y + view.getHeight())) {
        return false;
    }
    return true;
}

From source file:Main.java

/**
 * <pre>//from   w  ww. ja  va2  s  . com
 * Determine whether a {@link MotionEvent} is on a {@link View}
 * </pre>
 */
public static boolean motionEventOnView(MotionEvent event, View view) {
    int[] location = new int[2];
    view.getLocationOnScreen(location);
    int x = location[0];
    int y = location[1];
    int w = view.getWidth();
    int h = view.getHeight();
    Rect rect = new Rect(x, y, x + w, y + h);
    return rect.contains((int) event.getRawX(), (int) event.getRawY());
}

From source file:it.sephiroth.android.library.imagezoom.ScaleGestureDetector.java

/**
 * MotionEvent has no getRawY(int) method; simulate it pending future API
 * approval./*from  ww w . jav  a  2s.c  om*/
 */
private static float getRawY(final MotionEvent event, final int pointerIndex) {
    final float offset = event.getY() - event.getRawY();
    return event.getY(pointerIndex) + offset;
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Returns true if the provided touch event was within the provided view
 *
 * @return true if the provided touch event was within the provided view
 *//*from w ww .  j ava2 s . co  m*/
public static boolean isTouchInView(View view, MotionEvent event) {
    Rect rect = new Rect();
    view.getGlobalVisibleRect(rect);
    return rect.contains((int) event.getRawX(), (int) event.getRawY());
}

From source file:com.filemanager.free.ui.views.FastScroller.java

private float getRelativeTouchPosition(MotionEvent event) {
    float yInParent = event.getRawY() - Futils.getViewRawY(handle);
    return yInParent / (getHeightMinusPadding() - handle.getHeight());

}

From source file:com.tearoffcalendar.activities.FaceDownCardFragment.java

public boolean onTouch(View view, MotionEvent event) {
    // We need to register click here
    final float y = event.getRawY();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        deltaY = 0;/*  w  ww .j  a v  a2  s  .c  o  m*/
        clickStartedOnY = y;
        Log.v(TAG, "Click started on:" + String.valueOf(clickStartedOnY));
        break;
    case MotionEvent.ACTION_UP:
        Log.v(TAG, "Resulted deltaY:" + String.valueOf(deltaY));
        // This one is for when finger is up, not a rude gesture bro!
        if (deltaY >= DELTA_Y_MAX) {
            Log.v(TAG, "Greater than max of delta y - not a click!");
        } else {
            Log.v(TAG, "Smaller than max of delta y - a click!");
            if (null != onFaceDownCardClickListener) {
                Log.v(TAG, "Calling on face down card click listener");
                onFaceDownCardClickListener.onFaceDownCardClick();
            } else {
                Log.e(TAG, "On face down card click listener is missing!");
            }
        }
        deltaY = clickStartedOnY = 0;
        break;
    case MotionEvent.ACTION_POINTER_DOWN:
        break;
    case MotionEvent.ACTION_POINTER_UP:
        break;
    case MotionEvent.ACTION_MOVE:
        deltaY += Math.abs(y - clickStartedOnY);
        Log.v(TAG, "Current delta: " + String.valueOf(deltaY));
        break;
    }
    return false;
}