package com.androidbegin.buttonclicktutorial;


import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.RelativeLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

//https://sites.google.com/site/androidcheckinfo/android-alarm-example/android-alarm-for-specific-date

public class datepicker extends Activity 
{
	
	 TextView date_infos; 
	 Button valide;
	
	 private int year;
	 private int month;
	 private int day;
	 private int hour;
	 private int min;
	 
	 private DbAdapter dbHelper;
	 private SimpleCursorAdapter dataAdapter;
		
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
	        super.onCreate(savedInstanceState);
	        //setContentView(R.layout.datepicker_view);
	        setContentView(R.layout.picker01);
	    	
	        TimePicker TimePicker = (TimePicker) findViewById(R.id.timePicker1);
	        TimePicker.setIs24HourView(true); // to set 24 hours mode
	        
	        //final DatePicker DatePicker = (DatePicker) findViewById(R.id.datePicker1);
	        
	     

	        
	       
   }


    public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener{

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState){
            final Calendar calendar = Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH);
            int day = calendar.get(Calendar.DAY_OF_MONTH);

            /*
                Create a DatePickerDialog using Theme.

                    DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener listener,
                        int year, int monthOfYear, int dayOfMonth)
             */

            // DatePickerDialog THEME_DEVICE_DEFAULT_LIGHT
            DatePickerDialog dpd = new DatePickerDialog(getActivity(),
                    AlertDialog.THEME_DEVICE_DEFAULT_LIGHT,this,year,month,day);

            // DatePickerDialog THEME_DEVICE_DEFAULT_DARK
            //DatePickerDialog dpd2 = new DatePickerDialog(getActivity(),
            //        AlertDialog.THEME_DEVICE_DEFAULT_DARK,this,year,month,day);

            // DatePickerDialog THEME_HOLO_LIGHT
           // DatePickerDialog dpd3 = new DatePickerDialog(getActivity(),
            //        AlertDialog.THEME_HOLO_LIGHT,this,year,month,day);

            // DatePickerDialog THEME_HOLO_DARK
            //DatePickerDialog dpd4 = new DatePickerDialog(getActivity(),
            //        AlertDialog.THEME_HOLO_DARK,this,year,month,day);

            // DatePickerDialog THEME_TRADITIONAL
            //DatePickerDialog dpd5 = new DatePickerDialog(getActivity(),
            //        AlertDialog.THEME_TRADITIONAL,this,year,month,day);

            // Return the DatePickerDialog
            return  dpd;
        }

        public void onDateSet(DatePicker view, int year, int month, int day)
        {
            // Do something with the chosen date
        	//String dateString = year;
        	
        	String date_selected = String.valueOf(year)+" /"+String.valueOf(month+1)+" /"+String.valueOf(day);
        	date_infos.setText(date_selected);
        	
        	// set selected date into textview
        	//			tvDisplayDate.setText(new StringBuilder().append(month + 1)
        	//			   .append("-").append(day).append("-").append(year)
        	//			   .append(" "));
        	
        	
        	String pipo = "646464";
        }
        
        public void onCancel(DialogInterface dialog){
            // Send a message to confirm cancel button click
            Toast.makeText(getActivity(),"Date Picker Canceled.", Toast.LENGTH_SHORT).show();
        }
        
    }
}