use of android.app.TimePickerDialog in project bookish-tribble by Hestvik-Dymbe.
the class AddTask method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_task);
mDisplayDate = (TextView) findViewById(R.id.dateView);
mDisplayTime = (TextView) findViewById(R.id.timeView);
addButton = (Button) findViewById(R.id.add_button);
mDisplayDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(AddTask.this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, year, month, day);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
});
mDateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
month = month + 1;
Log.d(TAG, "onDateSet: mm/dd/yyy: " + month + "/" + day + "/" + year);
String date = day + "/" + month + "/" + year;
mDisplayDate.setText(date);
}
};
mDisplayTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(AddTask.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
mDisplayTime.setText(selectedHour + ":" + selectedMinute);
}
}, hour, minute, // Yes 24 hour time
true);
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
buttonPress();
}
});
}
use of android.app.TimePickerDialog in project android_packages_apps_Settings by DirtyUnicorns.
the class NightDisplaySettings method onCreateDialog.
@Override
public Dialog onCreateDialog(final int dialogId) {
if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
final LocalTime initialTime;
if (dialogId == DIALOG_START_TIME) {
initialTime = mController.getCustomStartTime();
} else {
initialTime = mController.getCustomEndTime();
}
final Context context = getContext();
final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
final LocalTime time = LocalTime.of(hourOfDay, minute);
if (dialogId == DIALOG_START_TIME) {
mController.setCustomStartTime(time);
} else {
mController.setCustomEndTime(time);
}
}
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
}
return super.onCreateDialog(dialogId);
}
use of android.app.TimePickerDialog in project open-event-orga-app by fossasia.
the class DateBindings method bindTime.
@BindingAdapter("time")
public static void bindTime(Button button, ObservableField<String> time) {
String format = DateUtils.FORMAT_24H;
bindTemporal(button, time, format, zonedDateTime -> new TimePickerDialog(button.getContext(), (picker, hourOfDay, minute) -> setPickedDate(LocalDateTime.of(zonedDateTime.toLocalDate(), LocalTime.of(hourOfDay, minute)), button, format, time), zonedDateTime.getHour(), zonedDateTime.getMinute(), true));
}
use of android.app.TimePickerDialog in project android_packages_apps_Settings by crdroidandroid.
the class NightDisplaySettings method onCreateDialog.
@Override
public Dialog onCreateDialog(final int dialogId) {
if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
final LocalTime initialTime;
if (dialogId == DIALOG_START_TIME) {
initialTime = mController.getCustomStartTime();
} else {
initialTime = mController.getCustomEndTime();
}
final Context context = getContext();
final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
final LocalTime time = LocalTime.of(hourOfDay, minute);
if (dialogId == DIALOG_START_TIME) {
mController.setCustomStartTime(time);
} else {
mController.setCustomEndTime(time);
}
}
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
}
return super.onCreateDialog(dialogId);
}
use of android.app.TimePickerDialog in project fitness-app by seemoo-lab.
the class UploadInteraction method selectTime.
/**
* Lets the user select time of the alarm to override.
*/
private void selectTime() {
final int hours;
final int minutes;
if (((Alarm) alarms.get(position)).isEmpty()) {
Calendar calendar = Calendar.getInstance();
hours = calendar.get(Calendar.HOUR_OF_DAY);
minutes = calendar.get(Calendar.MINUTE);
} else {
hours = ((Alarm) alarms.get(position)).getHours();
minutes = ((Alarm) alarms.get(position)).getMinutes();
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
TimePickerDialog mTimePickerDialog = new TimePickerDialog(activity, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hour, int minute) {
secondsAfterMidnight = hour * 3600 + minute * 60;
selectRepeat();
}
}, hours, minutes, true);
mTimePickerDialog.setTitle("Select time:");
mTimePickerDialog.setButton(TimePickerDialog.BUTTON_NEGATIVE, "", mTimePickerDialog);
mTimePickerDialog.setCancelable(false);
mTimePickerDialog.show();
}
});
}
Aggregations