| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -14,472 +14,494 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * limitations under the License.
 | 
					 | 
					 | 
					 | 
					 * limitations under the License.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 */
 | 
					 | 
					 | 
					 | 
					 */
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package net.micode.notes.ui;
 | 
					 | 
					 | 
					 | 
					 package net.micode.notes.ui;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.text.DateFormatSymbols;
 | 
					 | 
					 | 
					 | 
					 import java.text.DateFormatSymbols;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.util.Calendar;
 | 
					 | 
					 | 
					 | 
					 import java.util.Calendar;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import net.micode.notes.R;
 | 
					 | 
					 | 
					 | 
					 import net.micode.notes.R;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.content.Context;
 | 
					 | 
					 | 
					 | 
					 import android.content.Context;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.text.format.DateFormat;
 | 
					 | 
					 | 
					 | 
					 import android.text.format.DateFormat;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.view.View;
 | 
					 | 
					 | 
					 | 
					 import android.view.View;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.widget.FrameLayout;
 | 
					 | 
					 | 
					 | 
					 import android.widget.FrameLayout;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.widget.NumberPicker;
 | 
					 | 
					 | 
					 | 
					 import android.widget.NumberPicker;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					public class DateTimePicker extends FrameLayout {
 | 
					 | 
					 | 
					 | 
					 public class DateTimePicker extends FrameLayout {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     //FrameLayout是布局模板之一
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final boolean DEFAULT_ENABLE_STATE = true;
 | 
					 | 
					 | 
					 | 
					     //所有的子元素全部在屏幕的右上方
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private static final boolean DEFAULT_ENABLE_STATE = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOURS_IN_HALF_DAY = 12;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOURS_IN_ALL_DAY = 24;
 | 
					 | 
					 | 
					 | 
					     private static final int HOURS_IN_HALF_DAY = 12;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int DAYS_IN_ALL_WEEK = 7;
 | 
					 | 
					 | 
					 | 
					     private static final int HOURS_IN_ALL_DAY = 24;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int DATE_SPINNER_MIN_VAL = 0;
 | 
					 | 
					 | 
					 | 
					     private static final int DAYS_IN_ALL_WEEK = 7;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int DATE_SPINNER_MAX_VAL = DAYS_IN_ALL_WEEK - 1;
 | 
					 | 
					 | 
					 | 
					     private static final int DATE_SPINNER_MIN_VAL = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW = 0;
 | 
					 | 
					 | 
					 | 
					     private static final int DATE_SPINNER_MAX_VAL = DAYS_IN_ALL_WEEK - 1;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW = 23;
 | 
					 | 
					 | 
					 | 
					     private static final int HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW = 1;
 | 
					 | 
					 | 
					 | 
					     private static final int HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW = 23;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW = 12;
 | 
					 | 
					 | 
					 | 
					     private static final int HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW = 1;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int MINUT_SPINNER_MIN_VAL = 0;
 | 
					 | 
					 | 
					 | 
					     private static final int HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW = 12;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int MINUT_SPINNER_MAX_VAL = 59;
 | 
					 | 
					 | 
					 | 
					     private static final int MINUT_SPINNER_MIN_VAL = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int AMPM_SPINNER_MIN_VAL = 0;
 | 
					 | 
					 | 
					 | 
					     private static final int MINUT_SPINNER_MAX_VAL = 59;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private static final int AMPM_SPINNER_MAX_VAL = 1;
 | 
					 | 
					 | 
					 | 
					     private static final int AMPM_SPINNER_MIN_VAL = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private static final int AMPM_SPINNER_MAX_VAL = 1;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final NumberPicker mDateSpinner;
 | 
					 | 
					 | 
					 | 
					     //初始化控件
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final NumberPicker mHourSpinner;
 | 
					 | 
					 | 
					 | 
					     private final NumberPicker mDateSpinner;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final NumberPicker mMinuteSpinner;
 | 
					 | 
					 | 
					 | 
					     private final NumberPicker mHourSpinner;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private final NumberPicker mAmPmSpinner;
 | 
					 | 
					 | 
					 | 
					     private final NumberPicker mMinuteSpinner;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private Calendar mDate;
 | 
					 | 
					 | 
					 | 
					     private final NumberPicker mAmPmSpinner;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     //NumberPicker是数字选择器
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private String[] mDateDisplayValues = new String[DAYS_IN_ALL_WEEK];
 | 
					 | 
					 | 
					 | 
					     //这里定义的四个变量全部是在设置闹钟时需要选择的变量(如日期、时、分、上午或者下午)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private Calendar mDate;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private boolean mIsAm;
 | 
					 | 
					 | 
					 | 
					     //定义了Calendar类型的变量mDate,用于操作时间
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private String[] mDateDisplayValues = new String[DAYS_IN_ALL_WEEK];
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private boolean mIs24HourView;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private boolean mIsAm;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private boolean mIsEnabled = DEFAULT_ENABLE_STATE;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private boolean mIs24HourView;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private boolean mInitialising;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private boolean mIsEnabled = DEFAULT_ENABLE_STATE;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private OnDateTimeChangedListener mOnDateTimeChangedListener;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     private boolean mInitialising;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @Override
 | 
					 | 
					 | 
					 | 
					     private OnDateTimeChangedListener mOnDateTimeChangedListener;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal);
 | 
					 | 
					 | 
					 | 
					     private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            updateDateControl();
 | 
					 | 
					 | 
					 | 
					         @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    };
 | 
					 | 
					 | 
					 | 
					             updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					             onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @Override
 | 
					 | 
					 | 
					 | 
					     };//OnValueChangeListener,这是时间改变监听器,这里主要是对日期的监听
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
					 | 
					 | 
					 | 
					     //将现在日期的值传递给mDate;updateDateControl是同步操作
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            boolean isDateChanged = false;
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            Calendar cal = Calendar.getInstance();
 | 
					 | 
					 | 
					 | 
					     private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (!mIs24HourView) {
 | 
					 | 
					 | 
					 | 
					         //这里是对 小时(Hour) 的监听
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (!mIsAm && oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY) {
 | 
					 | 
					 | 
					 | 
					         @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
					 | 
					 | 
					 | 
					         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
					 | 
					 | 
					 | 
					             boolean isDateChanged = false;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    isDateChanged = true;
 | 
					 | 
					 | 
					 | 
					             Calendar cal = Calendar.getInstance();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } else if (mIsAm && oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
 | 
					 | 
					 | 
					 | 
					             //声明一个Calendar的变量cal,便于后续的操作
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
					 | 
					 | 
					 | 
					             if (!mIs24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.add(Calendar.DAY_OF_YEAR, -1);
 | 
					 | 
					 | 
					 | 
					                 if (!mIsAm && oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    isDateChanged = true;
 | 
					 | 
					 | 
					 | 
					                     cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                     cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY ||
 | 
					 | 
					 | 
					 | 
					                     isDateChanged = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
 | 
					 | 
					 | 
					 | 
					                     //这里是对于12小时制时,晚上11点和12点交替时对日期的更改
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    mIsAm = !mIsAm;
 | 
					 | 
					 | 
					 | 
					                 } else if (mIsAm && oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					                     cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                     cal.add(Calendar.DAY_OF_YEAR, -1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else {
 | 
					 | 
					 | 
					 | 
					                     isDateChanged = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (oldVal == HOURS_IN_ALL_DAY - 1 && newVal == 0) {
 | 
					 | 
					 | 
					 | 
					                 } 
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
					 | 
					 | 
					 | 
					                 //这里是对于12小时制时,凌晨11点和12点交替时对日期的更改
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
					 | 
					 | 
					 | 
					                 if (oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY ||
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    isDateChanged = true;
 | 
					 | 
					 | 
					 | 
					                         oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } else if (oldVal == 0 && newVal == HOURS_IN_ALL_DAY - 1) {
 | 
					 | 
					 | 
					 | 
					                     mIsAm = !mIsAm;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
					 | 
					 | 
					 | 
					                     updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    cal.add(Calendar.DAY_OF_YEAR, -1);
 | 
					 | 
					 | 
					 | 
					                 }//这里是对于12小时制时,中午11点和12点交替时对AM和PM的更改
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    isDateChanged = true;
 | 
					 | 
					 | 
					 | 
					             } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                 if (oldVal == HOURS_IN_ALL_DAY - 1 && newVal == 0) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					                     cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int newHour = mHourSpinner.getValue() % HOURS_IN_HALF_DAY + (mIsAm ? 0 : HOURS_IN_HALF_DAY);
 | 
					 | 
					 | 
					 | 
					                     cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mDate.set(Calendar.HOUR_OF_DAY, newHour);
 | 
					 | 
					 | 
					 | 
					                     isDateChanged = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					                     //这里是对于24小时制时,晚上11点和12点交替时对日期的更改
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (isDateChanged) {
 | 
					 | 
					 | 
					 | 
					                 } else if (oldVal == 0 && newVal == HOURS_IN_ALL_DAY - 1) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                setCurrentYear(cal.get(Calendar.YEAR));
 | 
					 | 
					 | 
					 | 
					                     cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                setCurrentMonth(cal.get(Calendar.MONTH));
 | 
					 | 
					 | 
					 | 
					                     cal.add(Calendar.DAY_OF_YEAR, -1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                setCurrentDay(cal.get(Calendar.DAY_OF_MONTH));
 | 
					 | 
					 | 
					 | 
					                     isDateChanged = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					                 }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             } //这里是对于12小时制时,凌晨11点和12点交替时对日期的更改
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    };
 | 
					 | 
					 | 
					 | 
					             int newHour = mHourSpinner.getValue() % HOURS_IN_HALF_DAY + (mIsAm ? 0 : HOURS_IN_HALF_DAY);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					             //通过数字选择器对newHour的赋值
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
					 | 
					 | 
					 | 
					             mDate.set(Calendar.HOUR_OF_DAY, newHour);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @Override
 | 
					 | 
					 | 
					 | 
					             //通过set函数将新的Hour值传给mDate
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
					 | 
					 | 
					 | 
					             onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int minValue = mMinuteSpinner.getMinValue();
 | 
					 | 
					 | 
					 | 
					             if (isDateChanged) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int maxValue = mMinuteSpinner.getMaxValue();
 | 
					 | 
					 | 
					 | 
					                 setCurrentYear(cal.get(Calendar.YEAR));
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int offset = 0;
 | 
					 | 
					 | 
					 | 
					                 setCurrentMonth(cal.get(Calendar.MONTH));
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (oldVal == maxValue && newVal == minValue) {
 | 
					 | 
					 | 
					 | 
					                 setCurrentDay(cal.get(Calendar.DAY_OF_MONTH));
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                offset += 1;
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else if (oldVal == minValue && newVal == maxValue) {
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                offset -= 1;
 | 
					 | 
					 | 
					 | 
					     };
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (offset != 0) {
 | 
					 | 
					 | 
					 | 
					     private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mDate.add(Calendar.HOUR_OF_DAY, offset);
 | 
					 | 
					 | 
					 | 
					         @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mHourSpinner.setValue(getCurrentHour());
 | 
					 | 
					 | 
					 | 
					         //这里是对 分钟(Minute)改变的监听
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                updateDateControl();
 | 
					 | 
					 | 
					 | 
					         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                int newHour = getCurrentHourOfDay();
 | 
					 | 
					 | 
					 | 
					             int minValue = mMinuteSpinner.getMinValue();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (newHour >= HOURS_IN_HALF_DAY) {
 | 
					 | 
					 | 
					 | 
					             int maxValue = mMinuteSpinner.getMaxValue();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    mIsAm = false;
 | 
					 | 
					 | 
					 | 
					             int offset = 0;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					             //设置offset,作为小时改变的一个记录数据
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } else {
 | 
					 | 
					 | 
					 | 
					             if (oldVal == maxValue && newVal == minValue) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    mIsAm = true;
 | 
					 | 
					 | 
					 | 
					                 offset += 1;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					             } else if (oldVal == minValue && newVal == maxValue) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                 offset -= 1;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mDate.set(Calendar.MINUTE, newVal);
 | 
					 | 
					 | 
					 | 
					             //如果原值为59,新值为0,则offset加1
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					             //如果原值为0,新值为59,则offset减1
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             if (offset != 0) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    };
 | 
					 | 
					 | 
					 | 
					                 mDate.add(Calendar.HOUR_OF_DAY, offset);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					                 mHourSpinner.setValue(getCurrentHour());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
					 | 
					 | 
					 | 
					                 updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        @Override
 | 
					 | 
					 | 
					 | 
					                 int newHour = getCurrentHourOfDay();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
					 | 
					 | 
					 | 
					                 if (newHour >= HOURS_IN_HALF_DAY) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mIsAm = !mIsAm;
 | 
					 | 
					 | 
					 | 
					                     mIsAm = false;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (mIsAm) {
 | 
					 | 
					 | 
					 | 
					                     updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mDate.add(Calendar.HOUR_OF_DAY, -HOURS_IN_HALF_DAY);
 | 
					 | 
					 | 
					 | 
					                 } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else {
 | 
					 | 
					 | 
					 | 
					                     mIsAm = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mDate.add(Calendar.HOUR_OF_DAY, HOURS_IN_HALF_DAY);
 | 
					 | 
					 | 
					 | 
					                     updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					                 }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					             mDate.set(Calendar.MINUTE, newVal);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    };
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     };
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public interface OnDateTimeChangedListener {
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        void onDateTimeChanged(DateTimePicker view, int year, int month,
 | 
					 | 
					 | 
					 | 
					     private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                int dayOfMonth, int hourOfDay, int minute);
 | 
					 | 
					 | 
					 | 
					         //对AM和PM的监听
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public DateTimePicker(Context context) {
 | 
					 | 
					 | 
					 | 
					             mIsAm = !mIsAm;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this(context, System.currentTimeMillis());
 | 
					 | 
					 | 
					 | 
					             if (mIsAm) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					                 mDate.add(Calendar.HOUR_OF_DAY, -HOURS_IN_HALF_DAY);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					             } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public DateTimePicker(Context context, long date) {
 | 
					 | 
					 | 
					 | 
					                 mDate.add(Calendar.HOUR_OF_DAY, HOURS_IN_HALF_DAY);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this(context, date, DateFormat.is24HourFormat(context));
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					             updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					             onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public DateTimePicker(Context context, long date, boolean is24HourView) {
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super(context);
 | 
					 | 
					 | 
					 | 
					     };
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate = Calendar.getInstance();
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mInitialising = true;
 | 
					 | 
					 | 
					 | 
					     public interface OnDateTimeChangedListener {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mIsAm = getCurrentHourOfDay() >= HOURS_IN_HALF_DAY;
 | 
					 | 
					 | 
					 | 
					         void onDateTimeChanged(DateTimePicker view, int year, int month,
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        inflate(context, R.layout.datetime_picker, this);
 | 
					 | 
					 | 
					 | 
					                 int dayOfMonth, int hourOfDay, int minute);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner = (NumberPicker) findViewById(R.id.date);
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setMinValue(DATE_SPINNER_MIN_VAL);
 | 
					 | 
					 | 
					 | 
					     public DateTimePicker(Context context) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setMaxValue(DATE_SPINNER_MAX_VAL);
 | 
					 | 
					 | 
					 | 
					         this(context, System.currentTimeMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
 | 
					 | 
					 | 
					 | 
					     }//通过对数据库的访问,获取当前的系统时间
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mHourSpinner = (NumberPicker) findViewById(R.id.hour);
 | 
					 | 
					 | 
					 | 
					     public DateTimePicker(Context context, long date) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
 | 
					 | 
					 | 
					 | 
					         this(context, date, DateFormat.is24HourFormat(context));
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner =  (NumberPicker) findViewById(R.id.minute);
 | 
					 | 
					 | 
					 | 
					     }//上面函数的得到的是一个天文数字(1970至今的秒数),需要DateFormat将其变得有意义
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setMinValue(MINUT_SPINNER_MIN_VAL);
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setMaxValue(MINUT_SPINNER_MAX_VAL);
 | 
					 | 
					 | 
					 | 
					     public DateTimePicker(Context context, long date, boolean is24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setOnLongPressUpdateInterval(100);
 | 
					 | 
					 | 
					 | 
					         super(context);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
 | 
					 | 
					 | 
					 | 
					         //获取系统时间
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mDate = Calendar.getInstance();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        String[] stringsForAmPm = new DateFormatSymbols().getAmPmStrings();
 | 
					 | 
					 | 
					 | 
					         mInitialising = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner = (NumberPicker) findViewById(R.id.amPm);
 | 
					 | 
					 | 
					 | 
					         mIsAm = getCurrentHourOfDay() >= HOURS_IN_HALF_DAY;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setMinValue(AMPM_SPINNER_MIN_VAL);
 | 
					 | 
					 | 
					 | 
					         inflate(context, R.layout.datetime_picker, this);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setMaxValue(AMPM_SPINNER_MAX_VAL);
 | 
					 | 
					 | 
					 | 
					         //如果当前Activity里用到别的layout,比如对话框layout
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setDisplayedValues(stringsForAmPm);
 | 
					 | 
					 | 
					 | 
					         //还要设置这个layout上的其他组件的内容,就必须用inflate()方法先将对话框的layout找出来
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setOnValueChangedListener(mOnAmPmChangedListener);
 | 
					 | 
					 | 
					 | 
					         //然后再用findViewById()找到它上面的其它组件
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mDateSpinner = (NumberPicker) findViewById(R.id.date);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // update controls to initial state
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setMinValue(DATE_SPINNER_MIN_VAL);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateDateControl();
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setMaxValue(DATE_SPINNER_MAX_VAL);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateHourControl();
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mHourSpinner = (NumberPicker) findViewById(R.id.hour);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        set24HourView(is24HourView);
 | 
					 | 
					 | 
					 | 
					         mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner = (NumberPicker) findViewById(R.id.minute);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // set to current time
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setMinValue(MINUT_SPINNER_MIN_VAL);  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentDate(date);
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setMaxValue(MINUT_SPINNER_MAX_VAL);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setOnLongPressUpdateInterval(100);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setEnabled(isEnabled());
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // set the content descriptions
 | 
					 | 
					 | 
					 | 
					         String[] stringsForAmPm = new DateFormatSymbols().getAmPmStrings();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mInitialising = false;
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner = (NumberPicker) findViewById(R.id.amPm);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setMinValue(AMPM_SPINNER_MIN_VAL);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setMaxValue(AMPM_SPINNER_MAX_VAL);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setDisplayedValues(stringsForAmPm);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setEnabled(boolean enabled) {
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setOnValueChangedListener(mOnAmPmChangedListener);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mIsEnabled == enabled) {
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					         // update controls to initial state
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        super.setEnabled(enabled);
 | 
					 | 
					 | 
					 | 
					         updateHourControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setEnabled(enabled);
 | 
					 | 
					 | 
					 | 
					         updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setEnabled(enabled);
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mHourSpinner.setEnabled(enabled);
 | 
					 | 
					 | 
					 | 
					         set24HourView(is24HourView);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setEnabled(enabled);
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mIsEnabled = enabled;
 | 
					 | 
					 | 
					 | 
					         // set to current time
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         setCurrentDate(date);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override
 | 
					 | 
					 | 
					 | 
					         setEnabled(isEnabled());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public boolean isEnabled() {
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mIsEnabled;
 | 
					 | 
					 | 
					 | 
					         // set the content descriptions
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         mInitialising = false;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get the current date in millis
 | 
					 | 
					 | 
					 | 
					     @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					     public void setEnabled(boolean enabled) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return the current date in millis
 | 
					 | 
					 | 
					 | 
					         if (mIsEnabled == enabled) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public long getCurrentDateInTimeMillis() {
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.getTimeInMillis();
 | 
					 | 
					 | 
					 | 
					         super.setEnabled(enabled);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setEnabled(enabled);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setEnabled(enabled);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					         mHourSpinner.setEnabled(enabled);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set the current date
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setEnabled(enabled);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					         mIsEnabled = enabled;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param date The current date in millis
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					     //存在疑问!!!!!!!!!!!!!setEnabled的作用
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentDate(long date) {
 | 
					 | 
					 | 
					 | 
					     //下面的代码通过原程序的注释已经比较清晰,另外可以通过函数名来判断
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Calendar cal = Calendar.getInstance();
 | 
					 | 
					 | 
					 | 
					     //下面的各函数主要是对上面代码引用到的各函数功能的实现
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        cal.setTimeInMillis(date);
 | 
					 | 
					 | 
					 | 
					     @Override
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
 | 
					 | 
					 | 
					 | 
					     public boolean isEnabled() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
 | 
					 | 
					 | 
					 | 
					         return mIsEnabled;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set the current date
 | 
					 | 
					 | 
					 | 
					      * Get the current date in millis
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param year The current year
 | 
					 | 
					 | 
					 | 
					      * @return the current date in millis
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param month The current month
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param dayOfMonth The current dayOfMonth
 | 
					 | 
					 | 
					 | 
					     public long getCurrentDateInTimeMillis() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param hourOfDay The current hourOfDay
 | 
					 | 
					 | 
					 | 
					         return mDate.getTimeInMillis();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param minute The current minute
 | 
					 | 
					 | 
					 | 
					     }//实现函数——得到当前的秒数
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentDate(int year, int month,
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int dayOfMonth, int hourOfDay, int minute) {
 | 
					 | 
					 | 
					 | 
					      * Set the current date
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentYear(year);
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentMonth(month);
 | 
					 | 
					 | 
					 | 
					      * @param date The current date in millis
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentDay(dayOfMonth);
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentHour(hourOfDay);
 | 
					 | 
					 | 
					 | 
					     public void setCurrentDate(long date) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentMinute(minute);
 | 
					 | 
					 | 
					 | 
					         Calendar cal = Calendar.getInstance();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         cal.setTimeInMillis(date);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         setCurrentDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					                 cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get current year
 | 
					 | 
					 | 
					 | 
					     }//实现函数功能——设置当前的时间,参数是date
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return The current year
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					      * Set the current date
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public int getCurrentYear() {
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.get(Calendar.YEAR);
 | 
					 | 
					 | 
					 | 
					      * @param year The current year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					      * @param month The current month
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					      * @param dayOfMonth The current dayOfMonth
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      * @param hourOfDay The current hourOfDay
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set current year
 | 
					 | 
					 | 
					 | 
					      * @param minute The current minute
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param year The current year
 | 
					 | 
					 | 
					 | 
					     public void setCurrentDate(int year, int month,
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					             int dayOfMonth, int hourOfDay, int minute) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentYear(int year) {
 | 
					 | 
					 | 
					 | 
					         setCurrentYear(year);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mInitialising && year == getCurrentYear()) {
 | 
					 | 
					 | 
					 | 
					         setCurrentMonth(month);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					         setCurrentDay(dayOfMonth);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         setCurrentHour(hourOfDay);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate.set(Calendar.YEAR, year);
 | 
					 | 
					 | 
					 | 
					         setCurrentMinute(minute);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateDateControl();
 | 
					 | 
					 | 
					 | 
					     }//实现函数功能——设置当前的时间,参数是各详细的变量
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					      * Get current year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get current month in the year
 | 
					 | 
					 | 
					 | 
					      * @return The current year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return The current month in the year
 | 
					 | 
					 | 
					 | 
					     //下面是得到year、month、day等值
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					     public int getCurrentYear() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public int getCurrentMonth() {
 | 
					 | 
					 | 
					 | 
					         return mDate.get(Calendar.YEAR);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.get(Calendar.MONTH);
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      * Set current year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set current month in the year
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      * @param year The current year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param month The month in the year
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					     public void setCurrentYear(int year) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentMonth(int month) {
 | 
					 | 
					 | 
					 | 
					         if (!mInitialising && year == getCurrentYear()) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mInitialising && month == getCurrentMonth()) {
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         mDate.set(Calendar.YEAR, year);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate.set(Calendar.MONTH, month);
 | 
					 | 
					 | 
					 | 
					         updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateDateControl();
 | 
					 | 
					 | 
					 | 
					         onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      * Get current month in the year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get current day of the month
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      * @return The current month in the year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return The day of the month
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					     public int getCurrentMonth() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public int getCurrentDay() {
 | 
					 | 
					 | 
					 | 
					         return mDate.get(Calendar.MONTH);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.get(Calendar.DAY_OF_MONTH);
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      * Set current month in the year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set current day of the month
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      * @param month The month in the year
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param dayOfMonth The day of the month
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					     public void setCurrentMonth(int month) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentDay(int dayOfMonth) {
 | 
					 | 
					 | 
					 | 
					         if (!mInitialising && month == getCurrentMonth()) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mInitialising && dayOfMonth == getCurrentDay()) {
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         mDate.set(Calendar.MONTH, month);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
 | 
					 | 
					 | 
					 | 
					         updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateDateControl();
 | 
					 | 
					 | 
					 | 
					         onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					      * Get current day of the month
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get current hour in 24 hour mode, in the range (0~23)
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return The current hour in 24 hour mode
 | 
					 | 
					 | 
					 | 
					      * @return The day of the month
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public int getCurrentHourOfDay() {
 | 
					 | 
					 | 
					 | 
					     public int getCurrentDay() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.get(Calendar.HOUR_OF_DAY);
 | 
					 | 
					 | 
					 | 
					         return mDate.get(Calendar.DAY_OF_MONTH);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private int getCurrentHour() {
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mIs24HourView){
 | 
					 | 
					 | 
					 | 
					      * Set current day of the month
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return getCurrentHourOfDay();
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else {
 | 
					 | 
					 | 
					 | 
					      * @param dayOfMonth The day of the month
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int hour = getCurrentHourOfDay();
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (hour > HOURS_IN_HALF_DAY) {
 | 
					 | 
					 | 
					 | 
					     public void setCurrentDay(int dayOfMonth) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                return hour - HOURS_IN_HALF_DAY;
 | 
					 | 
					 | 
					 | 
					         if (!mInitialising && dayOfMonth == getCurrentDay()) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else {
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                return hour == 0 ? HOURS_IN_HALF_DAY : hour;
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					         mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         updateDateControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set current hour in 24 hour mode, in the range (0~23)
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					      * Get current hour in 24 hour mode, in the range (0~23)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param hourOfDay
 | 
					 | 
					 | 
					 | 
					      * @return The current hour in 24 hour mode
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentHour(int hourOfDay) {
 | 
					 | 
					 | 
					 | 
					     public int getCurrentHourOfDay() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mInitialising && hourOfDay == getCurrentHourOfDay()) {
 | 
					 | 
					 | 
					 | 
					         return mDate.get(Calendar.HOUR_OF_DAY);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
 | 
					 | 
					 | 
					 | 
					     private int getCurrentHour() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mIs24HourView) {
 | 
					 | 
					 | 
					 | 
					         if (mIs24HourView){
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (hourOfDay >= HOURS_IN_HALF_DAY) {
 | 
					 | 
					 | 
					 | 
					             return getCurrentHourOfDay();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mIsAm = false;
 | 
					 | 
					 | 
					 | 
					         } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (hourOfDay > HOURS_IN_HALF_DAY) {
 | 
					 | 
					 | 
					 | 
					             int hour = getCurrentHourOfDay();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    hourOfDay -= HOURS_IN_HALF_DAY;
 | 
					 | 
					 | 
					 | 
					             if (hour > HOURS_IN_HALF_DAY) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                 return hour - HOURS_IN_HALF_DAY;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else {
 | 
					 | 
					 | 
					 | 
					             } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mIsAm = true;
 | 
					 | 
					 | 
					 | 
					                 return hour == 0 ? HOURS_IN_HALF_DAY : hour;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (hourOfDay == 0) {
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    hourOfDay = HOURS_IN_HALF_DAY;
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					      * Set current hour in 24 hour mode, in the range (0~23)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mHourSpinner.setValue(hourOfDay);
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					      * @param hourOfDay
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     public void setCurrentHour(int hourOfDay) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					         if (!mInitialising && hourOfDay == getCurrentHourOfDay()) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Get currentMinute
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return The Current Minute
 | 
					 | 
					 | 
					 | 
					         mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					         if (!mIs24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public int getCurrentMinute() {
 | 
					 | 
					 | 
					 | 
					             if (hourOfDay >= HOURS_IN_HALF_DAY) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mDate.get(Calendar.MINUTE);
 | 
					 | 
					 | 
					 | 
					                 mIsAm = false;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					                 if (hourOfDay > HOURS_IN_HALF_DAY) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					                     hourOfDay -= HOURS_IN_HALF_DAY;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					                 }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set current minute
 | 
					 | 
					 | 
					 | 
					             } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					                 mIsAm = true;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setCurrentMinute(int minute) {
 | 
					 | 
					 | 
					 | 
					                 if (hourOfDay == 0) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!mInitialising && minute == getCurrentMinute()) {
 | 
					 | 
					 | 
					 | 
					                     hourOfDay = HOURS_IN_HALF_DAY;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					                 }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mMinuteSpinner.setValue(minute);
 | 
					 | 
					 | 
					 | 
					             updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDate.set(Calendar.MINUTE, minute);
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        onDateTimeChanged();
 | 
					 | 
					 | 
					 | 
					         mHourSpinner.setValue(hourOfDay);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return true if this is in 24 hour view else false.
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					      * Get currentMinute
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public boolean is24HourView () {
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return mIs24HourView;
 | 
					 | 
					 | 
					 | 
					      * @return The Current Minute
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					     public int getCurrentMinute() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					         return mDate.get(Calendar.MINUTE);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set whether in 24 hour or AM/PM mode.
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     *
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param is24HourView True for 24 hour mode. False for AM/PM mode.
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					      * Set current minute
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void set24HourView(boolean is24HourView) {
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mIs24HourView == is24HourView) {
 | 
					 | 
					 | 
					 | 
					     public void setCurrentMinute(int minute) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return;
 | 
					 | 
					 | 
					 | 
					         if (!mInitialising && minute == getCurrentMinute()) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mIs24HourView = is24HourView;
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mAmPmSpinner.setVisibility(is24HourView ? View.GONE : View.VISIBLE);
 | 
					 | 
					 | 
					 | 
					         mMinuteSpinner.setValue(minute);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int hour = getCurrentHourOfDay();
 | 
					 | 
					 | 
					 | 
					         mDate.set(Calendar.MINUTE, minute);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateHourControl();
 | 
					 | 
					 | 
					 | 
					         onDateTimeChanged();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setCurrentHour(hour);
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        updateAmPmControl();
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					      * @return true if this is in 24 hour view else false.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void updateDateControl() {
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Calendar cal = Calendar.getInstance();
 | 
					 | 
					 | 
					 | 
					     public boolean is24HourView () {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
					 | 
					 | 
					 | 
					         return mIs24HourView;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        cal.add(Calendar.DAY_OF_YEAR, -DAYS_IN_ALL_WEEK / 2 - 1);
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setDisplayedValues(null);
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (int i = 0; i < DAYS_IN_ALL_WEEK; ++i) {
 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
					 | 
					 | 
					 | 
					      * Set whether in 24 hour or AM/PM mode.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
 | 
					 | 
					 | 
					 | 
					      *
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					      * @param is24HourView True for 24 hour mode. False for AM/PM mode.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setDisplayedValues(mDateDisplayValues);
 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
 | 
					 | 
					 | 
					 | 
					     public void set24HourView(boolean is24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mDateSpinner.invalidate();
 | 
					 | 
					 | 
					 | 
					         if (mIs24HourView == is24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					             return;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void updateAmPmControl() {
 | 
					 | 
					 | 
					 | 
					         mIs24HourView = is24HourView;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mIs24HourView) {
 | 
					 | 
					 | 
					 | 
					         mAmPmSpinner.setVisibility(is24HourView ? View.GONE : View.VISIBLE);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mAmPmSpinner.setVisibility(View.GONE);
 | 
					 | 
					 | 
					 | 
					         int hour = getCurrentHourOfDay();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else {
 | 
					 | 
					 | 
					 | 
					         updateHourControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            int index = mIsAm ? Calendar.AM : Calendar.PM;
 | 
					 | 
					 | 
					 | 
					         setCurrentHour(hour);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mAmPmSpinner.setValue(index);
 | 
					 | 
					 | 
					 | 
					         updateAmPmControl();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mAmPmSpinner.setVisibility(View.VISIBLE);
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					     private void updateDateControl() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         Calendar cal = Calendar.getInstance();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void updateHourControl() {
 | 
					 | 
					 | 
					 | 
					         cal.setTimeInMillis(mDate.getTimeInMillis());
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mIs24HourView) {
 | 
					 | 
					 | 
					 | 
					         cal.add(Calendar.DAY_OF_YEAR, -DAYS_IN_ALL_WEEK / 2 - 1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW);
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setDisplayedValues(null);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW);
 | 
					 | 
					 | 
					 | 
					         for (int i = 0; i < DAYS_IN_ALL_WEEK; ++i) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else {
 | 
					 | 
					 | 
					 | 
					             cal.add(Calendar.DAY_OF_YEAR, 1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW);
 | 
					 | 
					 | 
					 | 
					             mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW);
 | 
					 | 
					 | 
					 | 
					         }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setDisplayedValues(mDateDisplayValues);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					         mDateSpinner.invalidate();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /**
 | 
					 | 
					 | 
					 | 
					     }// 对于星期几的算法
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * Set the callback that indicates the 'Set' button has been pressed.
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param callback the callback, if null will do nothing
 | 
					 | 
					 | 
					 | 
					     private void updateAmPmControl() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */
 | 
					 | 
					 | 
					 | 
					         if (mIs24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public void setOnDateTimeChangedListener(OnDateTimeChangedListener callback) {
 | 
					 | 
					 | 
					 | 
					             mAmPmSpinner.setVisibility(View.GONE);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mOnDateTimeChangedListener = callback;
 | 
					 | 
					 | 
					 | 
					         } else {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					             int index = mIsAm ? Calendar.AM : Calendar.PM;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					             mAmPmSpinner.setValue(index);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void onDateTimeChanged() {
 | 
					 | 
					 | 
					 | 
					             mAmPmSpinner.setVisibility(View.VISIBLE);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (mOnDateTimeChangedListener != null) {
 | 
					 | 
					 | 
					 | 
					         }// 对于上下午操作的算法
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(),
 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    getCurrentMonth(), getCurrentDay(), getCurrentHourOfDay(), getCurrentMinute());
 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					     private void updateHourControl() {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					         if (mIs24HourView) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					             mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					             mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         } else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					             mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					             mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         }// 对与小时的算法
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     /**
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      * Set the callback that indicates the 'Set' button has been pressed.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      * @param callback the callback, if null will do nothing
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      */
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     public void setOnDateTimeChangedListener(OnDateTimeChangedListener callback) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         mOnDateTimeChangedListener = callback;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     private void onDateTimeChanged() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         if (mOnDateTimeChangedListener != null) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					             mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                     getCurrentMonth(), getCurrentDay(), getCurrentHourOfDay(), getCurrentMinute());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         }  
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 }
 |