use of android.app.TimePickerDialog in project robolectric by robolectric.
the class ShadowTimePickerDialogTest method updateTime_shouldUpdateHourAndMinute.
@Test
public void updateTime_shouldUpdateHourAndMinute() {
TimePickerDialog timePickerDialog = new TimePickerDialog(ApplicationProvider.getApplicationContext(), 0, null, 6, 55, true);
timePickerDialog.updateTime(1, 2);
Bundle bundle = timePickerDialog.onSaveInstanceState();
assertThat(bundle.getInt("hour")).isEqualTo(1);
assertThat(bundle.getInt("minute")).isEqualTo(2);
}
use of android.app.TimePickerDialog in project Gadgetbridge by Freeyourgadget.
the class ReminderDetails method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reminder_details);
reminder = (Reminder) getIntent().getSerializableExtra(Reminder.EXTRA_REMINDER);
if (reminder == null) {
GB.toast("No reminder provided to ReminderDetails Activity", Toast.LENGTH_LONG, GB.ERROR);
finish();
return;
}
reminderRepeat = findViewById(R.id.reminder_repeat);
reminderDate = findViewById(R.id.reminder_date);
reminderTime = findViewById(R.id.reminder_time);
reminderText = findViewById(R.id.reminder_message);
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
final String[] repeatStrings = getResources().getStringArray(R.array.reminder_repeat);
repeatAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, repeatStrings);
final View cardRepeat = findViewById(R.id.card_repeat);
cardRepeat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new AlertDialog.Builder(ReminderDetails.this).setAdapter(repeatAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
reminder.setRepetition(i);
updateUiFromReminder();
}
}).create().show();
}
});
final View cardDate = findViewById(R.id.card_date);
cardDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Calendar date = new GregorianCalendar();
date.setTime(reminder.getDate());
new DatePickerDialog(ReminderDetails.this, ReminderDetails.this, date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)).show();
}
});
final View cardTime = findViewById(R.id.card_time);
cardTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new TimePickerDialog(ReminderDetails.this, ReminderDetails.this, reminder.getDate().getHours(), reminder.getDate().getMinutes(), DateFormat.is24HourFormat(GBApplication.getContext())).show();
}
});
reminderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(coordinator.getMaximumReminderMessageLength()) });
reminderText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(final CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(final CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(final Editable s) {
reminder.setMessage(s.toString());
}
});
final FloatingActionButton fab = findViewById(R.id.fab_save);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateReminder();
ReminderDetails.this.setResult(1);
finish();
}
});
updateUiFromReminder();
}
use of android.app.TimePickerDialog in project Etar-Calendar by Etar-Group.
the class SnoozeDelayActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_DELAY) {
TimePickerDialog d = new TimePickerDialog(this, this, 0, 0, true);
d.setTitle(R.string.snooze_delay_dialog_title);
d.setCancelable(true);
d.setOnCancelListener(this);
return d;
}
return super.onCreateDialog(id);
}
use of android.app.TimePickerDialog in project MyDiary by erttyy8821.
the class TimePickerFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
savedTime = getArguments().getLong("savedTime", -1);
Calendar calendar = Calendar.getInstance();
if (savedTime != -1) {
calendar.setTimeInMillis(savedTime);
}
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
// The bug was triggered only on Chinese.
return new TimePickerDialog(getActivity(), ThemeManager.getInstance().getPickerStyle(), onTimeSetListener, hour, minute, true);
}
use of android.app.TimePickerDialog in project mobile-center-sdk-android by Microsoft.
the class TimePickerFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(getInitialTime());
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
return new TimePickerDialog(getActivity(), mListener, hour, minute, true);
}
Aggregations