package com.cookandroid.project6_1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.Chronometer;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.TimePicker;

public class MainActivity extends AppCompatActivity {

	Chronometer chrono;
	Button btnStart, btnEnd;
	RadioButton rdoCal, rdoTime;
	CalendarView calView;
	TimePicker tPicker;
	TextView tvYear, tvMonth, tvDay, tvHour, tvMinute;
	int selectYear, selectMonth, selectDay;

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

		setTitle("시간 예약");

		// 버튼
		btnStart = (Button) findViewById(R.id.btnStart);
		btnEnd = (Button) findViewById(R.id.btnEnd);

		// 크로노미터
		chrono = (Chronometer) findViewById(R.id.chronometer1);

		// 라디오버튼 2개
		rdoCal = (RadioButton) findViewById(R.id.rdoCal);
		rdoTime = (RadioButton) findViewById(R.id.rdoTime);

		// FrameLayout의 2개 위젯
		tPicker = (TimePicker) findViewById(R.id.timePicker1);
		calView = (CalendarView) findViewById(R.id.calendarView1);

		// 텍스트뷰 중에서 연,월,일,시,분 숫자
		tvYear = (TextView) findViewById(R.id.tvYear);
		tvMonth = (TextView) findViewById(R.id.tvMonth);
		tvDay = (TextView) findViewById(R.id.tvDay);
		tvHour = (TextView) findViewById(R.id.tvHour);
		tvMinute = (TextView) findViewById(R.id.tvMinute);

		// 처음에는 2개를 안보이게 설정
		tPicker.setVisibility(View.INVISIBLE);
		calView.setVisibility(View.INVISIBLE);

		rdoCal.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				tPicker.setVisibility(View.INVISIBLE);
				calView.setVisibility(View.VISIBLE);
			}
		});

		rdoTime.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				tPicker.setVisibility(View.VISIBLE);
				calView.setVisibility(View.INVISIBLE);
			}
		});

	}
}
