|
@@ -7,9 +7,11 @@ import android.app.AlertDialog.Builder;
|
|
|
import android.app.Dialog;
|
|
|
import android.app.DialogFragment;
|
|
|
import android.content.DialogInterface;
|
|
|
+import android.content.res.Configuration;
|
|
|
import android.os.Bundle;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.widget.DatePicker;
|
|
|
import android.widget.DatePicker.OnDateChangedListener;
|
|
|
import android.widget.TimePicker;
|
|
@@ -53,25 +55,22 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
|
|
|
}
|
|
|
|
|
|
public DateTimeDialogFragment(Activity activity, int DialogType) {
|
|
|
+
|
|
|
this.activity = activity;
|
|
|
this.DialogType = DialogType;
|
|
|
|
|
|
- // Inflate layout for the view
|
|
|
- // Pass null as the parent view because its going in the dialog layout
|
|
|
LayoutInflater inflater = activity.getLayoutInflater();
|
|
|
- mView = inflater.inflate(R.layout.date_time_dialog, null);
|
|
|
+ mView = inflater.inflate(R.layout.date_time_dialog, null);
|
|
|
|
|
|
- // Grab a Calendar instance
|
|
|
+ this.setupRootView(mView);
|
|
|
+ /*
|
|
|
mCalendar = Calendar.getInstance();
|
|
|
|
|
|
- // Init date picker
|
|
|
datePicker = (DatePicker) mView.findViewById(R.id.DatePicker);
|
|
|
datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), this);
|
|
|
|
|
|
- // Init time picker
|
|
|
timePicker = (TimePicker) mView.findViewById(R.id.TimePicker);
|
|
|
|
|
|
- // Set default Calendar and Time Style
|
|
|
setIs24HourView(true);
|
|
|
setCalendarViewShown(false);
|
|
|
|
|
@@ -83,6 +82,47 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
|
|
|
datePicker.setVisibility(View.GONE);
|
|
|
break;
|
|
|
}
|
|
|
+ */
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onConfigurationChanged(Configuration newConfig){
|
|
|
+ super.onConfigurationChanged(newConfig);
|
|
|
+ LayoutInflater inflater = LayoutInflater.from(this.activity);
|
|
|
+
|
|
|
+ ViewGroup container = (ViewGroup) this.mView.getParent();
|
|
|
+
|
|
|
+ container.removeView(this.mView);
|
|
|
+
|
|
|
+ mView = inflater.inflate(R.layout.date_time_dialog, null);
|
|
|
+ container.addView(mView);
|
|
|
+ this.setupRootView(mView);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setupRootView(View mView){
|
|
|
+ // Grab a Calendar instance
|
|
|
+ mCalendar = Calendar.getInstance();
|
|
|
+
|
|
|
+ // Init date picker
|
|
|
+ datePicker = (DatePicker) mView.findViewById(R.id.DatePicker);
|
|
|
+ datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), this);
|
|
|
+
|
|
|
+ // Init time picker
|
|
|
+ timePicker = (TimePicker) mView.findViewById(R.id.TimePicker);
|
|
|
+
|
|
|
+ // Set default Calendar and Time Style
|
|
|
+ setIs24HourView(true);
|
|
|
+ setCalendarViewShown(false);
|
|
|
+
|
|
|
+ switch (DialogType) {
|
|
|
+ case DATE_PICKER:
|
|
|
+ timePicker.setVisibility(View.GONE);
|
|
|
+ break;
|
|
|
+ case TIME_PICKER:
|
|
|
+ datePicker.setVisibility(View.GONE);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void setDate(long timeInMillis){
|