GestureOverlayView not working

I am now kind of puzzeld:

I created 4 gestures using Gesturebuilder 1 Gesture is a napkin pointing upwards 2 Gesture is a napkin pointing downwards 3 Gesture is an arrow pointing to the left 4 Gesture is an arrow pointing to the right

but when I try to make a gesture in a running application, only the left and right are recognized, but also the seams, like up and down, are the same as left and right because the method gives me a receipt as a thumb

toast to scroll left shows: up, left

I also use custom view in my activity and OntouchListener, but I can not get it to work

Activity:

public class RunActivity extends Activity implements OnTouchListener, OnGesturePerformedListener {

    static int width;
    static int height;

    static boolean reset=false;


    draw d;


    //jump
    private GestureLibrary gestureLib;


private static Context mContext;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        d = new draw(this);
        d.setOnTouchListener(this);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        mContext = this;


        //get screen size
        WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();


        width = display.getWidth();  // deprecated
        height = display.getHeight();  // deprecated


        //Jump
        GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
        View inflate = d;
        gestureOverlayView.addView(inflate);
        gestureOverlayView.addOnGesturePerformedListener(this);
        gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
        if (!gestureLib.load()) {
            finish();
        }
        setContentView(gestureOverlayView);

        //setContentView(d);
    }
    public static Context getContext(){
        return mContext;
    }
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        Log.d("touch","touched");

        if (draw.end == true)
        {
        reset=true;
        }
        return false;
    }
    @Override
    public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
        ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
        for (Prediction prediction : predictions) {
            if (prediction.score > 1.0) {
                Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }

}
+3
source share
1 answer

onTouch() , , false , .

0

All Articles