Example usage for android.app TimePickerDialog TimePickerDialog

List of usage examples for android.app TimePickerDialog TimePickerDialog

Introduction

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

Prototype

public TimePickerDialog(Context context, OnTimeSetListener listener, int hourOfDay, int minute,
        boolean is24HourView) 

Source Link

Document

Creates a new time picker dialog.

Usage

From source file:co.carlosandresjimenez.android.gotit.TimePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}

From source file:com.simplaapliko.trips.presentation.fragment.SelectTimeDialog.java

@NonNull
@Override/*from   w  w w . j  a  v  a 2 s.  co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final TimePickerDialog pickerDialog = new TimePickerDialog(getActivity(), this,
            mCalendar.get(Calendar.HOUR_OF_DAY), mCalendar.get(Calendar.MINUTE),
            DateFormat.is24HourFormat(getActivity()));

    pickerDialog.setOnKeyListener((dialog, keyCode, event) -> {
        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            dialog.cancel();
            dialog.dismiss();
            return true;
        default:
            return false;
        }
    });

    return pickerDialog;
}

From source file:com.pos.libs.DatePickerDialogFragment.java

public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar c = Calendar.getInstance();
    if (isDatePicker) {
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        return new DatePickerDialog(getActivity(), this, year, month, day);

    } else {//w ww . j  ava 2  s  .  com
        int hours = c.get(Calendar.HOUR_OF_DAY);
        int minutes = c.get(Calendar.MINUTE);
        return new TimePickerDialog(getActivity(), this, hours, minutes, true);
    }
}

From source file:com.jaspersoft.android.jaspermobile.dialog.DateDialogFragment.java

@NonNull
@Override/*from www  .  j  a v  a2  s. c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (type == DATE) {
        return new DatePickerDialog(getActivity(), new DateChangeListener(), activeDate.get(Calendar.YEAR),
                activeDate.get(Calendar.MONTH), activeDate.get(Calendar.DAY_OF_MONTH));
    } else {
        return new TimePickerDialog(getActivity(), new TimeChangeListener(),
                activeDate.get(Calendar.HOUR_OF_DAY), activeDate.get(Calendar.MINUTE), true);
    }
}

From source file:org.gnucash.android.ui.TimePickerDialogFragment.java

/**
 * Creates and returns an Android {@link TimePickerDialog}
 *//*  w  ww .ja  va  2s  .  co m*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Calendar cal = mCurrentTime == null ? Calendar.getInstance() : mCurrentTime;

    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);

    return new TimePickerDialog(getActivity(), mListener, hour, minute, true);
}

From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.info.edit.TimePickerDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Calendar c = Calendar.getInstance();
    try {//from  ww  w .  j a va2s.  co  m
        Date d = Utils.FORMAT_TIME_UI.parse((String) getArguments().getString(DATA));
        c.setTime(d);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    if (getTimeEditText().getTag() != null) {
        c.setTime((Date) getTimeEditText().getTag());
    }

    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}

From source file:ca.mudar.parkcatcher.ui.fragments.TimePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    ((ParkingApp) getActivity().getApplicationContext()).updateUiLanguage();

    final GregorianCalendar c = mListener.getParkingCalendar();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}

From source file:roommateapp.info.droid.TimePickerFragment.java

/**
 * On create of the time picker dialog/*from  www .j av  a 2s  .  c om*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Create a new instance of TimePickerDialog and return it
    picker = new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));

    int cMin = DateHelper.getCurrentMinute();
    int cHour = DateHelper.getCurrentHour();
    String curTime = DateHelper.getTimeString(cHour, cMin);
    String selTime = DateHelper.getTimeString(hour, minute);
    String closingTime = DateHelper.getClosingTime(this.buildingActivity.getBuilding());
    int compareTimes = closingTime.compareTo(curTime);

    // Show a reset-button if the current time isnt the selected
    if (!curTime.equals(selTime) && compareTimes > 1) {

        picker.setButton(DialogInterface.BUTTON_NEUTRAL, this.c.getText(R.string.filter_reset),
                new DialogInterface.OnClickListener() {

                    // Set the selected time to the current time
                    public void onClick(DialogInterface dialog, int which) {

                        int cMin = DateHelper.getCurrentMinute();
                        int cHour = DateHelper.getCurrentHour();
                        buildingActivity.setTimebar(cHour, cMin);
                        picker.updateTime(cHour, cMin);
                    }
                });
    }
    return picker;
}

From source file:org.videolan.vlc.gui.TimePickerDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    action = getArguments().getInt("action");
    boolean is24 = true;
    int hour = 0;
    int minute = 0;
    if (action == ACTION_SLEEP) {
        // Use the current time as the default values for the picker
        final Calendar c = VLCApplication.sPlayerSleepTime != null ? VLCApplication.sPlayerSleepTime
                : Calendar.getInstance();
        hour = c.get(Calendar.HOUR_OF_DAY);
        minute = c.get(Calendar.MINUTE);
        is24 = DateFormat.is24HourFormat(getActivity());
    }//from  w  w w.  j a  v  a2 s. c om

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, is24);
}

From source file:com.lambdasoup.quickfit.ui.TimeDialogFragment.java

@NonNull
@Override/*from w w  w.j  av  a  2s.co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int hour = getArguments().getInt(KEY_OLD_HOUR);
    int minute = getArguments().getInt(KEY_OLD_MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}