package fr.iutfbleau.reticule;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Reticule reticule = this.findViewById(R.id.reticule);
        reticule.setOnTouchListener(new ControleurReticule(reticule));
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putFloat("coordX", this.findViewById(R.id.reticule).getX());
        outState.putFloat("coordY", this.findViewById(R.id.reticule).getY());
    }

    @Override
    protected void onRestoreInstanceState(Bundle inState) {
        super.onRestoreInstanceState(inState);
        float x = inState.getFloat("coordX");
        float y = inState.getFloat("coordY");
        Reticule reticule = this.findViewById(R.id.reticule);
        reticule.deplacerReticule((int) x, (int) y);
    }

}