Example usage for android.app TimePickerDialog show

List of usage examples for android.app TimePickerDialog show

Introduction

In this page you can find the example usage for android.app TimePickerDialog show.

Prototype

@Override
    public void show() 

Source Link

Usage

From source file:net.naonedbus.fragment.impl.ItineraireFragment.java

private void showTimePicker() {
    final TimePickerDialog dialog = new TimePickerDialog(getActivity(), this, mDateTime.getHourOfDay(),
            mDateTime.getMinuteOfHour(), true);
    dialog.show();
}

From source file:com.fastbootmobile.encore.app.MainActivity.java

private void showSleepTimerPicker() {
    TimePickerDialog dlg;
    if (Utils.hasLollipop()) {
        dlg = new TimePickerDialog(this, R.style.TimePickerAppDialog, this, 0, 0, true);
    } else {/*from  w  w  w .j av  a 2s .  c om*/
        dlg = new TimePickerDialog(this, this, 0, 0, true);
    }
    dlg.show();
}

From source file:com.fastbootmobile.encore.app.MainActivity.java

private void showSleepTimerPicker(int hour, int minute) {
    TimePickerDialog dlg;
    if (Utils.hasLollipop()) {
        dlg = new TimePickerDialog(this, R.style.TimePickerAppDialog, this, hour, minute, true);
    } else {/*from  www.j a  v  a 2 s . co  m*/
        dlg = new TimePickerDialog(this, this, hour, minute, true);
    }
    dlg.show();
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showEndsOnTimeDialog() {
    Calendar endTimeCalendar = Calendar.getInstance();
    endTimeCalendar.setTime(endDate);/* ww w  .j a  v  a 2 s .c o  m*/

    boolean is24HourFormat = android.text.format.DateFormat.is24HourFormat(context);

    OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            endDate = DateUtils.setHours(endDate, hourOfDay);
            endDate = DateUtils.setMinutes(endDate, minute);
            updateEndDateButtons();
        }
    };

    TimePickerDialog timePickerDialog = new TimePickerDialog(context, onTimeSetListener,
            endTimeCalendar.get(Calendar.HOUR_OF_DAY), endTimeCalendar.get(Calendar.MINUTE), is24HourFormat);
    timePickerDialog.setTitle(R.string.activity_edit_event_pick_end_time);
    timePickerDialog.show();
}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

private void showStartsOnTimeDialog() {
    Calendar startTimeCalendar = Calendar.getInstance();
    startTimeCalendar.setTime(startDate);

    boolean is24HourFormat = android.text.format.DateFormat.is24HourFormat(context);

    OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {

        @Override//from   w ww.  jav  a  2s .  com
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            long diff = endDate.getTime() - startDate.getTime();

            startDate = DateUtils.setHours(startDate, hourOfDay);
            startDate = DateUtils.setMinutes(startDate, minute);
            updateStartDateButtons();

            endDate.setTime(startDate.getTime() + diff);
            updateEndDateButtons();
        }
    };

    TimePickerDialog timePickerDialog = new TimePickerDialog(context, onTimeSetListener,
            startTimeCalendar.get(Calendar.HOUR_OF_DAY), startTimeCalendar.get(Calendar.MINUTE),
            is24HourFormat);
    timePickerDialog.setTitle(R.string.activity_edit_event_pick_start_time);
    timePickerDialog.show();

}

From source file:com.morgan.sunrisealarm.MainActivity.java

public void layoutClicked(View view) {
    final WidgetId widget = new WidgetId(view);

    Switch onOffSwitch = (Switch) findViewById(widget.getSwitchId());
    if (onOffSwitch.isChecked()) {
        final TextView alarmText = (TextView) findViewById(widget.getAlarmTextId());

        AlarmTime time = new AlarmTime(alarmText.getText().toString());
        TimePickerDialog timePicker;

        timePicker = new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() {
            @Override// w  ww .ja v a2s . com
            public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
                AlarmTime time = new AlarmTime(selectedHour, selectedMinute);
                alarmText.setText(time.getString());

                Command command = new Command();
                command.setAlarm(widget.getAlarmId(), selectedHour, selectedMinute);
            }
        }, time.getHour(), time.getMin(), true);
        timePicker.show();
    }
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Handler for the change get date button
 * //from   ww w .  j a v  a2s . c o m
 * @param v
 *            view that launch the event
 */
public void onChangeGetTimeClick(View v) {
    Calendar cal;
    TimePickerDialog dlg;
    TimePickerDialog.OnTimeSetListener lt;

    cal = Calendar.getInstance();

    lt = new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hour, int minute) {
            onGetTimeSet(view, hour, minute);
        }
    };

    cal.setTime(_movement.getGetDate());

    dlg = new TimePickerDialog(this, lt, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);

    dlg.show();
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Handler for the change insert time button
 * //from  ww w .  j  a va 2 s  .c  o  m
 * @param v
 *            view that launch the event
 */
public void onChangeInsertTimeClick(View v) {
    Calendar cal;
    TimePickerDialog dlg;
    TimePickerDialog.OnTimeSetListener lt;

    cal = Calendar.getInstance();

    lt = new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hour, int minute) {
            onInsertTimeSet(view, hour, minute);
        }
    };

    cal.setTime(_movement.getInsertDate());

    dlg = new TimePickerDialog(this, lt, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);

    dlg.show();
}

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 v a 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.itime.team.itime.fragments.MeetingSubPreferenceFragment.java

@Override
public void onClick(View v) {
    final int id = v.getId();
    switch (id) {
    case R.id.setting_meeting_start_date: {
        final Calendar cal = Calendar.getInstance();
        DatePickerDialog datePicker = new DatePickerDialog(getContext(),
                new DatePickerDialog.OnDateSetListener() {
                    @Override//from  w  w w  .j  a va2  s .  co  m
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                        mStartsDate.setText(String.format("%d/%d/%d", dayOfMonth, monthOfYear + 1, year));
                        mStartsDateCalendar.set(year, monthOfYear, dayOfMonth);
                    }
                }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
        datePicker.show();
        break;
    }
    case R.id.setting_meeting_start_time:
    case R.id.setting_meeting_end_time: {
        final Calendar cal = Calendar.getInstance();
        TimePickerDialog timePicker = new TimePickerDialog(getContext(),
                new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        TextView time = id == R.id.setting_meeting_start_time ? mStartsTime : mEndsTime;

                        if (id == R.id.setting_meeting_start_time) {
                            mStartsTimeHour = hourOfDay;
                            mStartsTimeMinute = minute;
                        } else {
                            mEndsTimeHour = hourOfDay;
                            mEndsTimeMinute = minute;
                        }

                        time.setText(hourOfDay + ":" + minute);
                    }
                }, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), false);
        timePicker.show();
        break;
    }
    case R.id.setting_meeting_repeat: {
        Intent intent = new Intent(getActivity(), SettingsActivity.class);
        intent.putExtra("Settings", 6);
        startActivityForResult(intent, REPEAT_SETTINGS);

        break;
    }
    case R.id.setting_meeting_type: {
        String text = isPrefer ? Type.UNAVAILABLE.getText() : Type.PREFER.getText();
        isPrefer = !isPrefer;
        mType.setText(text);
        mParcelablePreference.preferenceType = text;
        break;
    }
    }
}