List of usage examples for android.app TimePickerDialog TimePickerDialog
public TimePickerDialog(Context context, OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView)
From source file:info.rynkowski.hamsterclient.ui.view.activity.FactFormActivity.java
@OnClick({ R.id.et_start_time, R.id.et_end_time }) public void onTimeClicked(final View view) { int hour, minutes; switch (view.getId()) { case R.id.et_start_time: hour = selectedStartTime.get(Calendar.HOUR_OF_DAY); minutes = selectedStartTime.get(Calendar.MINUTE); break;/*from w w w . ja va 2 s .co m*/ case R.id.et_end_time: hour = selectedEndTime.get(Calendar.HOUR_OF_DAY); minutes = selectedEndTime.get(Calendar.MINUTE); break; default: throw new AssertionError("Unknown view id"); } TimePickerDialog timePicker = new TimePickerDialog(FactFormActivity.this, (timePickerView, selectedHour, selectedMinutes) -> { switch (view.getId()) { case R.id.et_start_time: selectedStartTime.set(Calendar.HOUR_OF_DAY, selectedHour); selectedStartTime.set(Calendar.MINUTE, selectedMinutes); editTextStartTime.setText(TimeConverter.toString(selectedStartTime, "HH:mm")); break; case R.id.et_end_time: selectedEndTime.set(Calendar.HOUR_OF_DAY, selectedHour); selectedEndTime.set(Calendar.MINUTE, selectedMinutes); editTextEndTime.setText(TimeConverter.toString(selectedEndTime, "HH:mm")); break; } }, hour, minutes, true); timePicker.setTitle("Select Time"); timePicker.show(); }
From source file:com.kubotaku.android.sample.sensordataviewer.fragments.DateTimePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { loadTime();/*www . j a v a 2s .com*/ if (type == TYPE_PICKER_DATE) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); c.setTime(this.selectedDate); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } else { // Use the current time as the default values for the picker final Calendar c = Calendar.getInstance(); c.setTime(this.selectedDate); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); // Create a new instance of TimePickerDialog and return it return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity())); } }
From source file:com.kubotaku.android.code4kyoto5374.fragments.DateTimePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (type == TYPE_PICKER_DATE) { // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } else {/* w w w .ja v a2 s . c o m*/ // Create a new instance of TimePickerDialog and return it return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity())); } }
From source file:org.dvbviewer.controller.ui.fragments.DateDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(sDate);//from w w w .j a v a 2 s. com switch (type) { case TYPE_DATE: return new DatePickerDialog(sContext, mDateSetListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); case TYPE_TIME: return new TimePickerDialog(sContext, mTimeSetListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true); default: return null; } }
From source file:net.evecom.androidecssp.activity.taskresponse.TaskAddActivity.java
/** * /*w ww. j a va2 s . com*/ * * * @author Mars zhang * @created 2015-11-25 2:06:15 */ private void init() { tasknameeditText = (EditText) findViewById(R.id.taskadd_taskname_et); contenteditText = (EditText) findViewById(R.id.taskadd_taskcontern_et); remarkeditText = (EditText) findViewById(R.id.taskadd_remark_et); keywordeditText = (EditText) findViewById(R.id.taskadd_keyword_et); taskeffiView = (TextView) findViewById(R.id.taskadd_taskeffi_tv); taskpersonView = (EditText) findViewById(R.id.taskadd_taskpersonid_ed); taskdeptView = (EditText) findViewById(R.id.taskadd_taskdept_et); taskeffilinearLayout = (RelativeLayout) findViewById(R.id.taskadd_taskeffi_ll); calendar = Calendar.getInstance(); taskeffiView.setText(calendar.get(Calendar.YEAR) + "-" + calendar.get(Calendar.MONTH) + "-" + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE)); taskeffilinearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { new DatePickerDialog(instance, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker arg0, int year, int monthOfYear, int dayOfMonth) { taskeffiView.setText("" + year + "-" + (monthOfYear + 1) + "-" + dayOfMonth + " 00:00"); if (!istimePicked) { istimePicked = true; new TimePickerDialog(instance, new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { String tasteffivalue = taskeffiView.getText().toString(); String[] strs = tasteffivalue.split(" "); taskeffiView.setText(""); taskeffiView.setText(strs[0] + " " + hourOfDay + ":" + minute); istimePicked = false; } }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true).show(); } } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)) .show(); } }); }
From source file:jp.co.noxi.app.NXTimePickerDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (!mInitFlag) { throw new RuntimeException("User NXTimePickerDialog#newInstance"); }/*from ww w. j a va 2 s .c o m*/ final Bundle args = getArguments(); final int theme = args.getInt(ARG_THEME); final int hourOfDay = args.getInt(ARG_HOUR); final int minute = args.getInt(ARG_MINUTE); final boolean is24HourView = args.getBoolean(ARG_24HOUR); if (theme == VALUE_NULL) { return mDialog = new TimePickerDialog(getActivity(), this, hourOfDay, minute, is24HourView); } else { return mDialog = new TimePickerDialog(getActivity(), theme, this, hourOfDay, minute, is24HourView); } }
From source file:org.linesofcode.alltrack.graph.AddValueActivity.java
public void showTimePicker() { new TimePickerDialog(this, this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true) .show();//w w w .j a v a 2s .c o m }
From source file:com.mattprecious.smsfix.library.FixOld.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*w ww.j a va 2 s . co m*/ AlertDialog.Builder builder = new AlertDialog.Builder(this); switch (id) { case DIALOG_ID_START_DATE_PICKER: dialog = new DatePickerDialog(this, new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { startCalendar.set(year, monthOfYear, dayOfMonth); updateButtons(); } }, startCalendar.get(Calendar.YEAR), startCalendar.get(Calendar.MONTH), startCalendar.get(Calendar.DAY_OF_MONTH)); break; case DIALOG_ID_START_TIME_PICKER: dialog = new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { startCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); startCalendar.set(Calendar.MINUTE, minute); updateButtons(); } }, startCalendar.get(Calendar.HOUR_OF_DAY), startCalendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(this)); break; case DIALOG_ID_END_DATE_PICKER: dialog = new DatePickerDialog(this, new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { endCalendar.set(year, monthOfYear, dayOfMonth); updateButtons(); } }, endCalendar.get(Calendar.YEAR), endCalendar.get(Calendar.MONTH), endCalendar.get(Calendar.DAY_OF_MONTH)); break; case DIALOG_ID_END_TIME_PICKER: dialog = new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { endCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); endCalendar.set(Calendar.MINUTE, minute); updateButtons(); } }, endCalendar.get(Calendar.HOUR_OF_DAY), endCalendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(this)); break; case DIALOG_ID_OFFSET_PICKER: builder.setTitle(R.string.offset_hours); final EditText editText = new EditText(this); DecimalFormat df = new DecimalFormat("#.###"); editText.setText(df.format(Math.abs(offset) / 3600000f)); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL); builder.setView(editText); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { offset = (long) (Double.parseDouble(editText.getText().toString()) * 3600000); updateButtons(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog = builder.create(); break; case DIALOG_ID_CONFIRM: builder.setTitle(R.string.fix_old_confirm_title); builder.setMessage(R.string.fix_old_confirm_message); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fixMessages(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog = builder.create(); break; default: dialog = null; } return dialog; }
From source file:shetye.prathamesh.notifyme.Utilities.java
public void createWhenDialog(final Context context, final Activity parentActivity, final Notif note, final boolean back) { mDialog = new Dialog(context); mDialog.setContentView(R.layout.datetimepicker_dialog); mDialog.setTitle("When to Notify??"); mDialogOKBtn = (Button) mDialog.findViewById(R.id.btn_ok); mDialogOKBtn.setOnClickListener(new View.OnClickListener() { @Override//ww w .ja v a2 s . c om public void onClick(View v) { note.setNotification_when(getSelectedTime()); DatabaseHelper.getInstance(context).addNotif(note); setZoneInTimer(context, note); mDialog.dismiss(); if (parentActivity != null) { if (back) { parentActivity.finishAfterTransition(); } else { ((Notifications) parentActivity).refreshNotifications(); } } } }); mDialogOKBtn.setEnabled(false); mDialogCancelBtn = (Button) mDialog.findViewById(R.id.btn_cancel); mDialogCancelBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDialog.dismiss(); if (parentActivity != null) { parentActivity.finishAfterTransition(); } } }); mTimeBtn = (Button) mDialog.findViewById(R.id.btntimeset); mDateBtn = (Button) mDialog.findViewById(R.id.btndateset); final Time dtNow = new Time(); dtNow.setToNow(); mSelectedHours = dtNow.hour; mSelectedMinutes = dtNow.minute; mSelectedYear = dtNow.year; mSelectedMonth = dtNow.month; mSelectedDay = dtNow.monthDay; updateBtnText(dtNow, false, context); Time selectedTime = new Time(); selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth, mSelectedYear); mPastDateSelected = true; mTimeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Time selectedTime = new Time(); mSelectedHours = hourOfDay; mSelectedMinutes = minute; selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth, mSelectedYear); if (Time.compare(selectedTime, dtNow) <= 0) { mPastDateSelected = true; } else { mPastDateSelected = false; } updateBtnText(selectedTime, true, context); } }, mSelectedHours, mSelectedMinutes, false); timePickerDialog.show(); } }); mDateBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog datePickerDialog = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int yy, int mm, int dd) { Time selectedTime = new Time(); mSelectedYear = yy; mSelectedMonth = mm; mSelectedDay = dd; selectedTime.set(0, mSelectedMinutes, mSelectedHours, mSelectedDay, mSelectedMonth, mSelectedYear); if (Time.compare(selectedTime, dtNow) <= 0) { mPastDateSelected = true; } else { mPastDateSelected = false; } updateBtnText(selectedTime, false, context); } }, mSelectedYear, mSelectedMonth, mSelectedDay); datePickerDialog.show(); } }); mDialog.show(); }
From source file:com.karmick.android.citizenalert.alarm.AlarmAddActivity.java
protected void eventCalls() { alarm_add.setOnClickListener(new OnClickListener() { @Override// w w w. j a v a 2 s . c om public void onClick(View v) { validateAndSaveAlarm(); } }); alarm_contacts_add.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent nint = new Intent(AlarmAddActivity.this, ContactListActivity.class); nint.putExtra("for_result", true); startActivityForResult(nint, GETCONTACTS); } }); alarm_time.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TimePickerDialog timePickerDialog = new TimePickerDialog(AlarmAddActivity.this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int hours, int minutes) { newAlarmTime.set(Calendar.HOUR_OF_DAY, hours); newAlarmTime.set(Calendar.MINUTE, minutes); newAlarmTime.set(Calendar.SECOND, 0); newAlarmTime2.set(Calendar.HOUR_OF_DAY, hours); newAlarmTime2.set(Calendar.MINUTE, minutes); newAlarmTime2.set(Calendar.SECOND, 0); newAlarmTime3.set(Calendar.HOUR_OF_DAY, hours); newAlarmTime3.set(Calendar.MINUTE, minutes); newAlarmTime3.set(Calendar.SECOND, 0); alarm_time.setText(getAlarmTimeAsString(newAlarmTime)); } }, alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY), alarm.getAlarmTime().get(Calendar.MINUTE), true); timePickerDialog.setTitle("SetTime"); timePickerDialog.show(); } }); }