Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.view.MotionEvent;

public class Main {
    public static MotionEvent obtainMotionEvent(long downTime, long eventTime, int action, int id1, float x1,
            float y1) {
        int[] ids = new int[] { id1 };
        MotionEvent.PointerCoords[] coords = new MotionEvent.PointerCoords[] { createCoords(x1, y1) };
        return MotionEvent.obtain(downTime, eventTime, action, 1, ids, coords, 0, 1.0f, 1.0f, 0, 0, 0, 0);
    }

    public static MotionEvent obtainMotionEvent(long downTime, long eventTime, int action, int id1, float x1,
            float y1, int id2, float x2, float y2) {
        int[] ids = new int[] { id1, id2 };
        MotionEvent.PointerCoords[] coords = new MotionEvent.PointerCoords[] { createCoords(x1, y1),
                createCoords(x2, y2) };
        return MotionEvent.obtain(downTime, eventTime, action, 2, ids, coords, 0, 1.0f, 1.0f, 0, 0, 0, 0);
    }

    public static MotionEvent.PointerCoords createCoords(float x, float y) {
        MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords();
        pointerCoords.x = x;
        pointerCoords.y = y;
        return pointerCoords;
    }
}