package com.example.bb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class Reservation3 extends Activity {
    private static String TAG = "B&B Reservation";

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

        final CheckBox cb = (CheckBox) findViewById(R.id.smoking);
        cb.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                findViewById(R.id.room1).setEnabled(!cb.isChecked());
                findViewById(R.id.room2).setEnabled(!cb.isChecked());
                findViewById(R.id.room3).setEnabled(!cb.isChecked());
                findViewById(R.id.room4).setEnabled(cb.isChecked());
                findViewById(R.id.room5).setEnabled(cb.isChecked());
            }
        });

        Button done = (Button) findViewById(R.id.done);
        done.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                RadioGroup rg = (RadioGroup) findViewById(R.id.room);
                RadioButton rb =
                        (RadioButton) findViewById(rg
                                .getCheckedRadioButtonId());

                Log.v(TAG, "Smoking: " + cb.isChecked());
                if (rb != null) {
                    Log.v(TAG, "Room: " + rb.getText());
                }

                Intent i = new Intent();
                i.setClass(Reservation3.this, ThankYouActivity.class);
                startActivity(i);
            }
        });
    }
}