|
@@ -2,6 +2,7 @@ package com.usai.redant.rautils.dateTimePicker;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.NonNull;
|
|
|
|
|
+import android.support.annotation.Nullable;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
@@ -63,6 +64,10 @@ public class DateTimePickerDialog extends BaseDialog {
|
|
|
mContext = context;
|
|
mContext = context;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setTitle(@Nullable CharSequence title) {
|
|
|
|
|
+ mTitleTv.setText(title);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public void setMode(DateTimePickerMode mode) {
|
|
public void setMode(DateTimePickerMode mode) {
|
|
|
mMode = mode;
|
|
mMode = mode;
|
|
@@ -78,7 +83,6 @@ public class DateTimePickerDialog extends BaseDialog {
|
|
|
View rootView = getRootView();
|
|
View rootView = getRootView();
|
|
|
|
|
|
|
|
mTitleTv = rootView.findViewById(R.id.ra_date_time_picker_title_tv);
|
|
mTitleTv = rootView.findViewById(R.id.ra_date_time_picker_title_tv);
|
|
|
- mTitleTv.setText("请选择日期");
|
|
|
|
|
|
|
|
|
|
LinearLayout loopPanel = rootView.findViewById(R.id.ra_date_time_picker_loop_panel);
|
|
LinearLayout loopPanel = rootView.findViewById(R.id.ra_date_time_picker_loop_panel);
|
|
|
setupPicker(loopPanel);
|
|
setupPicker(loopPanel);
|
|
@@ -164,7 +168,7 @@ public class DateTimePickerDialog extends BaseDialog {
|
|
|
// Date
|
|
// Date
|
|
|
mDatePicker = DatePickerView.buildDatePickerView(mContext, DatePickerView.DatePickerViewLayoutMode.DATE_PICKER_VIEW_LAYOUT_MODE_COMPACT);
|
|
mDatePicker = DatePickerView.buildDatePickerView(mContext, DatePickerView.DatePickerViewLayoutMode.DATE_PICKER_VIEW_LAYOUT_MODE_COMPACT);
|
|
|
LinearLayout.LayoutParams dateLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
LinearLayout.LayoutParams dateLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
|
- dateLayoutParams.setMargins(0,0,RAUtil.dp2px(mContext, 20), 0);
|
|
|
|
|
|
|
+ dateLayoutParams.setMargins(0,0,RAUtil.dp2px(mContext, 5), 0);
|
|
|
panel.addView(mDatePicker, dateLayoutParams);
|
|
panel.addView(mDatePicker, dateLayoutParams);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -189,6 +193,33 @@ public class DateTimePickerDialog extends BaseDialog {
|
|
|
super.show();
|
|
super.show();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void setCalendar(Calendar calendar) {
|
|
|
|
|
+ if (calendar != null) {
|
|
|
|
|
+
|
|
|
|
|
+ if (mDatePicker != null) {
|
|
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1;
|
|
|
|
|
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
|
|
+
|
|
|
|
|
+ mDatePicker.setYear(year);
|
|
|
|
|
+ mDatePicker.setMonth(month);
|
|
|
|
|
+ mDatePicker.setDay(day);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mTimePicker != null) {
|
|
|
|
|
+
|
|
|
|
|
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
|
|
|
|
+ int minute = calendar.get(Calendar.MINUTE);
|
|
|
|
|
+ int second = calendar.get(Calendar.SECOND);
|
|
|
|
|
+
|
|
|
|
|
+ mTimePicker.setHour(hour);
|
|
|
|
|
+ mTimePicker.setMinute(minute);
|
|
|
|
|
+ mTimePicker.setSecond(second);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static View setupRootView(Context context) {
|
|
private static View setupRootView(Context context) {
|
|
|
|
|
|
|
|
if (context == null) {
|
|
if (context == null) {
|