Search in sources :

Example 1 with TimePicker

use of android.widget.TimePicker in project RoboBinding by RoboBinding.

the class AbstractTimePickerAttributeTest method initializeViewAndListeners.

@Before
public void initializeViewAndListeners() {
    view = new TimePicker(RuntimeEnvironment.application);
    viewAddOn = new MockTimePickerAddOn(view);
}
Also used : TimePicker(android.widget.TimePicker) Before(org.junit.Before)

Example 2 with TimePicker

use of android.widget.TimePicker in project k-9 by k9mail.

the class TimePickerPreference method onCreateDialogView.

/*
     * (non-Javadoc)
     *
     * @see android.preference.DialogPreference#onCreateDialogView()
     */
@Override
protected View onCreateDialogView() {
    TimePicker tp = new TimePicker(getContext());
    tp.setIs24HourView(DateFormat.is24HourFormat(getContext()));
    tp.setOnTimeChangedListener(this);
    originalHour = getHour();
    originalMinute = getMinute();
    if (originalHour >= 0 && originalMinute >= 0) {
        tp.setCurrentHour(originalHour);
        tp.setCurrentMinute(originalMinute);
    }
    return tp;
}
Also used : TimePicker(android.widget.TimePicker)

Example 3 with TimePicker

use of android.widget.TimePicker in project weex-example by KalicyZhou.

the class DatePickerImpl method pickTime.

public static void pickTime(@NonNull Context context, String value, @NonNull final OnPickListener listener) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(parseTime(value));
    TimePickerDialog dialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            String h = hourOfDay < 10 ? "0" + hourOfDay : String.valueOf(hourOfDay);
            String m = minute < 10 ? "0" + minute : String.valueOf(minute);
            String result = h + ":" + m;
            listener.onPick(true, result);
        }
    }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            listener.onPick(false, null);
        }
    });
    dialog.show();
}
Also used : TimePicker(android.widget.TimePicker) DialogInterface(android.content.DialogInterface) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog)

Example 4 with TimePicker

use of android.widget.TimePicker in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NightDisplaySettings method onCreateDialog.

@Override
public Dialog onCreateDialog(final int dialogId) {
    if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
        final NightDisplayController.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 NightDisplayController.LocalTime time = new NightDisplayController.LocalTime(hourOfDay, minute);
                if (dialogId == DIALOG_START_TIME) {
                    mController.setCustomStartTime(time);
                } else {
                    mController.setCustomEndTime(time);
                }
            }
        }, initialTime.hourOfDay, initialTime.minute, use24HourFormat);
    }
    return super.onCreateDialog(dialogId);
}
Also used : NightDisplayController(com.android.internal.app.NightDisplayController) Context(android.content.Context) TimePicker(android.widget.TimePicker) TimePickerDialog(android.app.TimePickerDialog)

Example 5 with TimePicker

use of android.widget.TimePicker in project cw-omnibus by commonsguy.

the class TimePickerDemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TimePicker picker = (TimePicker) findViewById(R.id.picker);
    picker.setOnTimeChangedListener(this);
}
Also used : TimePicker(android.widget.TimePicker)

Aggregations

TimePicker (android.widget.TimePicker)8 TimePickerDialog (android.app.TimePickerDialog)3 DialogInterface (android.content.DialogInterface)2 AlertDialog (android.app.AlertDialog)1 OnTimeSetListener (android.app.TimePickerDialog.OnTimeSetListener)1 Context (android.content.Context)1 NightDisplayController (com.android.internal.app.NightDisplayController)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Before (org.junit.Before)1