package fr.iutfbleau.dev45.wamster.tp05ex02_arcenciel;

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

public class DetectClic extends GestureDetector.SimpleOnGestureListener{
    private long tempsPression;
    private static final int LONG_PRESS_TIME = 500;
    private View view;
    private ListeCouleur gestionCouleur;

    public DetectClic(View view){
        this.view = view;
        this.gestionCouleur = new ListeCouleur();
    }

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

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        if (System.currentTimeMillis() - this.tempsPression < DetectClic.LONG_PRESS_TIME) {
            this.view.setBackgroundColor(this.gestionCouleur.couleurSuivante());
            Log.v("test","Single Tap");
            return true;
        }
        return false;
    }

    @Override
    public boolean onDoubleTap(MotionEvent e) {
        Log.v("test","Double Tap");
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        Log.v("test","Long Press");
    }
}
