Search in sources :

Example 26 with TimePickerDialog

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);
}
Also used : Bundle(android.os.Bundle) TimePickerDialog(android.app.TimePickerDialog) Test(org.junit.Test)

Example 27 with TimePickerDialog

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();
}
Also used : InputFilter(android.text.InputFilter) DialogInterface(android.content.DialogInterface) DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) TimePickerDialog(android.app.TimePickerDialog) View(android.view.View) TextView(android.widget.TextView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) DeviceCoordinator(nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator)

Example 28 with TimePickerDialog

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);
}
Also used : TimePickerDialog(android.app.TimePickerDialog)

Example 29 with TimePickerDialog

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);
}
Also used : Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog)

Example 30 with TimePickerDialog

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);
}
Also used : Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) NonNull(androidx.annotation.NonNull)

Aggregations

TimePickerDialog (android.app.TimePickerDialog)64 TimePicker (android.widget.TimePicker)27 Calendar (java.util.Calendar)25 View (android.view.View)20 DatePickerDialog (android.app.DatePickerDialog)15 TextView (android.widget.TextView)14 Context (android.content.Context)11 DialogInterface (android.content.DialogInterface)11 AlertDialog (android.app.AlertDialog)9 Button (android.widget.Button)8 CompoundButton (android.widget.CompoundButton)7 Bundle (android.os.Bundle)6 DatePicker (android.widget.DatePicker)6 LocalTime (java.time.LocalTime)6 FrameLayout (android.widget.FrameLayout)5 SuppressLint (android.annotation.SuppressLint)4 Intent (android.content.Intent)4 LinearLayout (android.widget.LinearLayout)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4