MotionEvent setLocation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MotionEvent setLocation method.

This code example shows how to use the following methods:getAction, getX, getY, setLocation
        // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98 
 
        final Rect sourcePartial = mSourcePartial;
        final View target = mTarget;
 
        int x = (int)event.getX();
        int y = (int)event.getY();
 
        boolean sendToDelegate = false;
        boolean hit = true;
        boolean handled = false;
 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (sourcePartial.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            } 
            break; 
        case MotionEvent.ACTION_UP:

7
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
    @Override 
    public boolean dispatchTouchEvent(MotionEvent event) {
        if(mTitleBar != null) {
            final int sy = getScrollY();
            final int visTitleHeight = getVisibleTitleHeightCompat();
            final float x = event.getX();
            float y = event.getY();
 
            switch(event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:
                    if(y <= visTitleHeight) {
                        mTouchInTitleBar = true;
                    } 
                    break; 
 
                case MotionEvent.ACTION_MOVE:
                    mTouchMove = true;
                    break; 
 
                case MotionEvent.ACTION_UP:

8
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
        // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98 
 
        final Rect sourcePartial = mSourcePartial;
        final View target = mTarget;
 
        int x = (int)event.getX();
        int y = (int)event.getY();
 
        boolean sendToDelegate = false;
        boolean hit = true;
        boolean handled = false;
 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (sourcePartial.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            } 
            break; 
        case MotionEvent.ACTION_UP:

7
CodeRank
This code example shows how to use the following methods:getX, getY, setLocation
This code example shows how to use the following methods:getX, getY, setLocation
        view.popTransform();
    } 
 
    @Override 
    protected boolean dispatchTouchEvent(MotionEvent event) {
        float x = event.getX();
        float y = event.getY();
        float width = getWidth();
        float height = getHeight();
        switch (mOrientation) {
            case DOWN: event.setLocation(width - x, height - y); break;
            case LEFT: event.setLocation(height - y, x); break;
            case RIGHT: event.setLocation(y, width - x); break;
        } 
        boolean result = mChild.dispatchTouchEvent(event);
        event.setLocation(x, y);
        return result;
    } 
 
    public void setOrientation(int orientation) {
        if (mOrientation == orientation) return;
7
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
        // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98 
 
        final Rect sourcePartial = mSourcePartial;
        final View target = mTarget;
 
        int x = (int)event.getX();
        int y = (int)event.getY();
 
        boolean sendToDelegate = false;
        boolean hit = true;
        boolean handled = false;
 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (sourcePartial.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            } 
            break; 
        case MotionEvent.ACTION_UP:

7
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
        // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98 
 
        final Rect sourcePartial = mSourcePartial;
        final View target = mTarget;
 
        int x = (int)event.getX();
        int y = (int)event.getY();
 
        boolean sendToDelegate = false;
        boolean hit = true;
        boolean handled = false;
 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (sourcePartial.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            } 
            break; 
        case MotionEvent.ACTION_UP:

6
CodeRank
This code example shows how to use the following methods:getX, getY, setLocation
        view.popTransform();
    } 
 
    @Override 
    protected boolean dispatchTouchEvent(MotionEvent event) {
        float x = event.getX();
        float y = event.getY();
        float width = getWidth();
        float height = getHeight();
        switch (mOrientation) {
            case DOWN: event.setLocation(width - x, height - y); break;
            case LEFT: event.setLocation(height - y, x); break;
            case RIGHT: event.setLocation(y, width - x); break;
        } 
        boolean result = mChild.dispatchTouchEvent(event);
        event.setLocation(x, y);
        return result;
    } 
 
    public void setOrientation(int orientation) {
        if (mOrientation == orientation) return;
7
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
        // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98 
 
        final Rect sourcePartial = mSourcePartial;
        final View target = mTarget;
 
        int x = (int)event.getX();
        int y = (int)event.getY();
 
        boolean sendToDelegate = false;
        boolean hit = true;
        boolean handled = false;
 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (sourcePartial.contains(x, y)) {
                mDelegateTargeted = true;
                sendToDelegate = true;
            } 
            break; 
        case MotionEvent.ACTION_UP:

7
CodeRank
This code example shows how to use the following methods:getAction, getX, getY, setLocation
    public static boolean preDispatchTouchEvent(View view,MotionEvent event) {
        Matrix m=getViewMatrix(view);
        if (m!=null) {
            Matrix mi=new Matrix();
            if (m.invert(mi)) {
                float[] points=new float[]{event.getX(),event.getY()};
                mi.mapPoints(points);
                if (event.getAction()==MotionEvent.ACTION_DOWN && (
                    points[0]<view.getLeft() || points[0]>=view.getRight() ||
                    points[1]<view.getTop() || points[1]>=view.getBottom()))
                { 
                    return false; 
                } 
                event.setLocation(points[0],points[1]);
            } 
        } 
        return true; 
    } 
     
    public static void postGetHitRect(View view,Rect hitRect) {
6
CodeRank

Related MotionEvent setLocation Questions & Answers:

setLocation Method Overview
Set this event's location.
See Code Examples for other Android MotionEvent Methods: