package fr.iutfbleau.dessin;

import android.view.View;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class ControleurRadioGroup implements OnCheckedChangeListener {

    private Croix croix;
    private Carre carre;
    private Rond rond;
    private Triangle triangle;
    private View precedent;

    public ControleurRadioGroup(Croix croix, Carre carre, Rond rond, Triangle triangle) {
        this.croix = croix;
        this.carre = carre;
        this.rond = rond;
        this.triangle = triangle;
        this.precedent = croix;
    }

    @Override
    public void onCheckedChanged(RadioGroup g, int checkedId) {
        this.precedent.setVisibility(View.GONE);
        if (checkedId == R.id.radio_croix) {
            this.croix.setVisibility(View.VISIBLE);
            this.precedent = this.croix;
        } else if (checkedId == R.id.radio_carre) {
            this.carre.setVisibility(View.VISIBLE);
            this.precedent = this.carre;
        } else if (checkedId == R.id.radio_rond) {
            this.rond.setVisibility(View.VISIBLE);
            this.precedent = this.rond;
        } else {
            this.triangle.setVisibility(View.VISIBLE);
            this.precedent = this.triangle;
        }

    }
}
