package fr.iutfbleau.dev45.wamster.tp04ex03_dimension;

import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

public class DetecteClic extends GestureDetector.SimpleOnGestureListener {
    private static final int LONG_PRESS_TIME = 500;
    private Rectangle actualRectangle;
    private long tempsPression;

    public DetecteClic(){
        super();
    }
    public void setViewActuel(Rectangle rectangle){
        this.actualRectangle = rectangle;
    }

    @Override
    public boolean onDown(MotionEvent e) {
        this.tempsPression = System.currentTimeMillis();
        return true;
    }
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        return true;
    }

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        if (System.currentTimeMillis() - this.tempsPression < DetecteClic.LONG_PRESS_TIME) {
            return true;
        }
        return false;
    }

    @Override
    public boolean onDoubleTap(MotionEvent e) {
        this.actualRectangle.toggleEtat();
        return true;
    }
}
