Java 类android.app.TimePickerDialog 实例源码

项目:android-study    文件:DateUI.java   
private void showTime() {

    Calendar c = Calendar.getInstance();
    int mYear = c.get(Calendar.YEAR);
    int mMonth = c.get(Calendar.MONTH);
    int mDay = c.get(Calendar.DAY_OF_MONTH);
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog dialog =
        new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
          @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

          }
        }, mHour, mMinute, true);
    dialog.show();
  }
项目:reaction-test    文件:DialogHelper.java   
private static TimePickerDialog.OnTimeSetListener getOnTimeSetListener(final EditText txtDate) {
    TimePickerDialog.OnTimeSetListener listener = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            String hour = hourOfDay + "";
            if (hourOfDay < 10) {
                hour = "0" + hourOfDay;
            }
            String min = minute + "";
            if (minute < 10)
                min = "0" + minute;
            txtDate.setText(hour + ":" + min);
        }
    };
    return listener;
}
项目:Sanxing    文件:OperateTaskActivityBase.java   
@OnClick(R.id.task_due_time_content)
void taskDueTimeOnClickBehavior() {
    TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hourOfDay, int minuteOfHour) {
            dueCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dueCalendar.set(Calendar.MINUTE, minuteOfHour);
            DateFormat sdf = android.text.format.DateFormat.getTimeFormat(getBaseContext());
            dueTimeContent.setText(sdf.format(dueCalendar.getTime()));
            setTime = true;
        }
    };
    new TimePickerDialog(this, time,
            dueCalendar.get(Calendar.HOUR_OF_DAY),
            dueCalendar.get(Calendar.MINUTE), true).show();
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出时间选择对话框
 * <p>
 * 参数:
 * title:标题
 * datetime 指定时间 yyyy-MM-dd HH:mm或者HH:mm
 * 返回:
 * time:格式:HH:mm
 */
public static void pickTime(IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        if (date.contains(" ")) {
            calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
        } else {
            calendar.setTime(DateUtil.convertString2Date(date, "HH:mm"));
        }
    }
    DialogUtil.pickTime(webLoader.getPageControl().getActivity(), title, calendar, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String chooseTime = DateUtil.convertDate(calendar.getTime(), "HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("time", chooseTime);
            callback.applySuccess(map);
        }
    });
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出日期时间选择对话框
 * <p>
 * 参数:
 * title:标题
 * datetime 指定时间 yyyy-MM-dd HH:mm
 * 返回:
 * datetime:格式:yyyy-MM-dd HH:mm
 */
public static void pickDateTime(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title1 = param.optString("title1");
    String title2 = param.optString("title2");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
    }
    DialogUtil.pickDateTime(webLoader.getPageControl().getActivity(), title1, title2, calendar, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("datetime", chooseDate);
            callback.applySuccess(map);
        }
    });
}
项目:puremadrid    文件:DatePickerFragment.java   
public void onDateSet() {
    final TimePickerDialog timePicker = new TimePickerDialog(getActivity(), this, hour, minute, true);

    timePicker.setCanceledOnTouchOutside(true);
    timePicker.setCancelable(true);

    timePicker.setButton(DialogInterface.BUTTON_NEGATIVE, "Ahora", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int which) {
            final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("CET"));
            timePicker.updateTime(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE));
            onTimeSet(null, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE));
        }
    });
    timePicker.show();
}
项目:KTools    文件:KDialogActivity.java   
@OnClick(R.id.btn_choose_time_dialog)
public void onBtnChooseTimeDialogClicked() {
    final Calendar calendar = Calendar.getInstance();
    TimePickerDialog dialog = new TimePickerDialog(
            this,
            new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    calendar.set(Calendar.MINUTE, minute);
                    String time = DateFormat.getTimeInstance(DateFormat.SHORT).format(calendar.getTime());
                    ToastUtils.showShortToast(time);
                }
            },
            calendar.get(Calendar.HOUR_OF_DAY),
            calendar.get(Calendar.MINUTE),
            false
    );
    dialog.show();
}
项目:Toodoo    文件:ToodooNote.java   
public void reminderTimePickerDialog() {
    final Calendar calendar = Calendar.getInstance();
    int mHour = calendar.get(Calendar.HOUR_OF_DAY);
    int mMinute = calendar.get(Calendar.MINUTE);

    final SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("hh:mm a", Locale.US);

    final ToodooTimePickerDialog timePickerDialog = new ToodooTimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hour, int minute) {
            reminderCalendar.set(Calendar.HOUR_OF_DAY, hour);
            reminderCalendar.set(Calendar.MINUTE, minute);
            selectedReminderValue = reminderCalendar.getTime();
            reminderTimeValue = simpleTimeFormat.format(selectedReminderValue);

            selectedReminder = reminderDateValue + " @ " + reminderTimeValue;

            ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(2);
            ToodooOptionsModel.setOptionValue(selectedReminder);
            mAdapter.notifyDataSetChanged();
        }
    }, mHour, mMinute, true);
    timePickerDialog.show();
}
项目:WeatherAlarmClock    文件:EditAlarmActivity.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
项目:NightLight    文件:AutoFragment.java   
/**
 * Shows time picker dialog and handles the time selected by user
 * @param viewWhoIsCallingIt View whose time time needs to be updated after user selects time
 * @param prefKey Preference for the key needed to be updated after user selects time
 */
private void showTimePickerDialog(final KeyValueView viewWhoIsCallingIt, final String prefKey) {
    int time[] = TimeUtils.getCurrentTimeAsHourAndMinutes();
    TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int i, int i1) {
            String selectedHour = i < 10 ? "0" + i: "" + i;
            String selectedMinute = i1 < 10 ? "0" +i1: "" + i1;
            String timeString = selectedHour + ":" + selectedMinute;

            PreferenceHelper.putString(context, prefKey, timeString);
            // We also backup the time here
            // To get the prefKey for backup, its "last_" + prefKey
            PreferenceHelper.putString(context, "last_" + prefKey, timeString);

            viewWhoIsCallingIt.setValue(timeString);

            addNextDayIfNecessary();

            doCurrentAutoFunctions(true);
        }
    }, time[0], time[1], false);
    timePickerDialog.show();
}
项目:Beach-Android    文件:PollActivity.java   
private void openTimePicker(){
    final Calendar c = Calendar.getInstance();
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog timePickerDialog = new TimePickerDialog(this,
            new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay,
                                      int minute) {
                    String date = btnPollExpiryTime.getText().toString();
                    btnPollExpiryTime.setText(date+" "+ hourOfDay + ":" + minute);
                }
            }, mHour, mMinute, false);
    timePickerDialog.show();
}
项目:RoomBookerMVP    文件:NewEventActivity.java   
private void displayTimePicker(final EditText destination) {
    TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setOnTimeSetListener(new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String displayTime = simpleTimeFormat.format(calendar.getTime());
            destination.setText(displayTime);
            switch (destination.getId()) {
                case R.id.ane_start_time:
                    newEventPresenter.setStartTime(hourOfDay, minute);
                    break;
                case R.id.ane_end_time:
                    newEventPresenter.setEndTime(hourOfDay, minute);
                    break;
            }
        }
    });
    timePickerFragment.show(getSupportFragmentManager(), TimePickerFragment.TAG);
}
项目:yield    文件:EventEditView.java   
private void showTimePicker(final boolean startTime) {
    final Calendar dateTime = startTime ? mEvent.localStart : mEvent.localEnd;
    new TimePickerDialog(getContext(),
            new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    dateTime.set(Calendar.MINUTE, minute);
                    mSwitchAllDay.setChecked(false);
                    setTime(startTime);
                }
            },
            dateTime.get(Calendar.HOUR_OF_DAY),
            dateTime.get(Calendar.MINUTE),
            false)
            .show();
}
项目:Mad-Planner    文件:AddExam.java   
/**
 * Pick the time that the homework item is due in for.
 */
public void pickTime() {
    TimePickerDialog dialog = new TimePickerDialog(AddExam.this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            hours = hourOfDay;
            minutes = minute;

            exam.setPeriod(-1);
            exam.setTime(Methods.convert(hourOfDay) + ":" + Methods.convert(minute));
            timeChecker = true;

            showUpdate();
            showSubmit();
            updateSwitcher(dateChecker, timeChecker);
        }
    }, hours, minutes, true);
    dialog.show();
}
项目:Mad-Planner    文件:AddHomework.java   
/**
 * Pick the time that the homework item is due in for.
 */
public void pickTime() {
    TimePickerDialog dialog = new TimePickerDialog(AddHomework.this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            hours = hourOfDay;
            minutes = minute;

            homeworkItem.setPeriod(-1);
            homeworkItem.setTime(Methods.convert(hourOfDay) + ":" + Methods.convert(minute));
            timeChecker = true;

            showUpdate();
            showSubmit();
            updateSwitcher(dateChecker, timeChecker);
        }
    }, hours, minutes, true);
    dialog.show();
}
项目:lucky-calories    文件:CaloriesFilterListFragment.java   
@OnClick(R.id.btnFromTime)
public void onclickFromTime(){
    FragmentManager fm = getChildFragmentManager();
    TimePickerFragment timeDialog = new TimePickerFragment();
    timeDialog.setListener(new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            Calendar cl = Calendar.getInstance();
            cl.set(Calendar.HOUR_OF_DAY, hourOfDay);
            cl.set(Calendar.MINUTE, minute);

            filterModel.setFromTime(cl.getTime());
            txtFromTime.setText(new SimpleDateFormat(timeFormat).format(filterModel.getFromTime()));
        }
    });
    timeDialog.show(fm, "fragment_edit_time");
}
项目:lucky-calories    文件:CaloriesFilterListFragment.java   
@OnClick(R.id.btnToTime)
public void onclickToTime(){
    FragmentManager fm = getChildFragmentManager();
    TimePickerFragment timeDialog = new TimePickerFragment();
    timeDialog.setListener(new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            Calendar cl = Calendar.getInstance();
            cl.set(Calendar.HOUR_OF_DAY, hourOfDay);
            cl.set(Calendar.MINUTE, minute);

            filterModel.setToTime(cl.getTime());
            txtToTime.setText(new SimpleDateFormat(timeFormat).format(filterModel.getToTime()));
        }
    });
    timeDialog.show(fm, "fragment_edit_time");
}
项目:ShoppingList    文件:ScheduleShoppingList.java   
@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.schedule_notificatin_display_time:
        new TimePickerDialog(getContext(), timePickerListener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true).show();
        break;

    case R.id.schedule_notificatin_display_date:
        new DatePickerDialog(getContext(), datePickerListener, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show();
        break;
    case R.id.schedule_notificatin_cancel:
        dismiss();
        break;

    case R.id.schedule_notificatin_schedule:
        AlarmeNotificationShoppingList.initAlarme(getContext(), idShoppingList, calendar);
        Toast.makeText(getContext(), getContext().getResources().getString(R.string.new_notification_seted) + " " + CustomDateFormat.getFormatedCompletedDate(new Date(calendar.getTimeInMillis())), Toast.LENGTH_LONG).show();
        dismiss();
        break;
    }
}
项目:wakemeapp    文件:TimePickerFragment.java   
@NonNull
@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);

  Bundle extras = getArguments();
  if (extras != null) {
    hour = extras.getInt(HOUR_ARG);
    minute = extras.getInt(MINUTE_ARG);
  }

  // Create a new instance of TimePickerDialog and return it
  return new TimePickerDialog(getActivity(), mListener, hour, minute,
          DateFormat.is24HourFormat(getActivity()));
}
项目:FMTech    文件:bzj.java   
public final Dialog c(Bundle paramBundle)
{
  if (this.Z == -1)
  {
    this.Z = paramBundle.getInt("type", -1);
    this.aa = paramBundle.getBoolean("cancelled", this.aa);
  }
  long l = this.m.getLong("date_time");
  String str = this.m.getString("time_zone");
  Calendar localCalendar = Calendar.getInstance();
  localCalendar.setTimeZone(hxk.a(str));
  localCalendar.setTimeInMillis(l);
  TimePickerDialog localTimePickerDialog = new TimePickerDialog(f(), this, localCalendar.get(11), localCalendar.get(12), DateFormat.is24HourFormat(f()));
  if (this.Z == 0)
  {
    int i = aau.dV;
    localTimePickerDialog.setButton(-2, g().getString(i), this);
  }
  return localTimePickerDialog;
}
项目:sensordatacollector    文件:TimePickerListener.java   
@Override
public void onClick(View v)
{
    if(edittext == null) {
        return;
    }

    String[] time;

    if(edittext.getText().toString().equals("")) {
        Calendar c = Calendar.getInstance();
        time = new String[2];
        time[0] = (c.get(Calendar.HOUR_OF_DAY) < 10) ? "0" + c.get(Calendar.HOUR_OF_DAY) : "" + c.get(Calendar.HOUR_OF_DAY);
        time[1] = (c.get(Calendar.MINUTE) < 10) ? "0" + c.get(Calendar.MINUTE) : "" + c.get(Calendar.MINUTE);
    } else {
        time = edittext.getText().toString().split(":");
    }

    TimePickerDialog dialog = new TimePickerDialog(context, timePickerListener, Integer.parseInt(time[0]), Integer.parseInt(time[1]), true);

    dialog.show();
}
项目:easy-a    文件:TimePickerDialogFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Find the TaskEditFragment that created this dialog. We'll
    // use that fragment as the edit callback, so that when the user
    // chooses a new date in our datepicker dialog,
    // the dialog will call back into the edit fragment to set the
    // new date.
    OnTimeSetListener listener = (OnTimeSetListener)
            getFragmentManager()
                    .findFragmentByTag(
                            TaskEditFragment
                                    .DEFAULT_FRAGMENT_TAG);

    // Construct a new TimePicker Dialog that will be hosted by
    // this fragment. Set its Hour and Minutes to the values
    // specified in the args bundle
    Bundle args = getArguments();
    return new TimePickerDialog(getActivity(), listener,
            args.getInt(HOUR),
            args.getInt(MINS), false);
}
项目:RoomBookerMVP    文件:NewEventActivity.java   
private void displayTimePicker(final EditText destination) {
    TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setOnTimeSetListener(new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String displayTime = simpleTimeFormat.format(calendar.getTime());
            destination.setText(displayTime);
            switch (destination.getId()) {
                case R.id.ane_start_time:
                    newEventPresenter.setStartTime(hourOfDay, minute);
                    break;
                case R.id.ane_end_time:
                    newEventPresenter.setEndTime(hourOfDay, minute);
                    break;
            }
        }
    });
    timePickerFragment.show(getSupportFragmentManager(), TimePickerFragment.TAG);
}
项目:qksms    文件:TimePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mPreference == null) {
        Log.w(TAG, "No preference set");
        return null;
    }

    mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");

    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();

    try {
        Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
        c.setTime(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity());
    return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
项目:worker    文件:TimePickerFragment.java   
public static TimePickerFragment newInstance(
        TimePickerDialog.OnTimeSetListener onTimeSetListener
) {
    TimePickerFragment fragment = new TimePickerFragment();
    fragment.onTimeSetListener = onTimeSetListener;

    return fragment;
}
项目:yield    文件:EventEditView.java   
private void showTimePicker(final boolean startTime) {
    final Calendar dateTime = startTime ? mEvent.localStart : mEvent.localEnd;
    new TimePickerDialog(getContext(),
            new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    dateTime.set(Calendar.MINUTE, minute);
                    mSwitchAllDay.setChecked(false);
                    setTime(startTime);
                }
            },
            dateTime.get(Calendar.HOUR_OF_DAY),
            dateTime.get(Calendar.MINUTE),
            false)
            .show();
}
项目:Terminightor    文件:AlarmItemDetailFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    dbHandler = AlarmDBOpenHelper.getAlarmDBOpenHelper(getActivity());

    timePickerDialog = new TimePickerDialog(getActivity(), R.style.AppTheme_Timepicker,
            new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            try {
                alarm.setHour(hourOfDay);
                alarm.setMinute(minute);
            } catch(Exception e) {
                e.printStackTrace();
            }
            setAlarmTimeView.setText(alarm.getTimeString(use24Hours));
            setAlarmAMPMView.setText(alarm.getAMPMSuffix(use24Hours));
            timeValueSet = true;
        }
    }, 0, 0, true);

    use24Hours = PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getBoolean(this.getString(R.string.use24Hours), false);
}
项目:android-app-common-tasks    文件:Common.java   
/**
 * show timepicker
 *
 * @param mContext
 * @param mTextView formar of the time
 * @return show timepicker
 */
public static void showTimePickerDialog(final Context mContext,
                                        final TextView mTextView) {
    new TimePickerDialog(mContext, new OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm a");
            dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dateTime.set(Calendar.MINUTE, minute);

            mTextView.setText(timeFormatter.format(dateTime.getTime()));
        }
    }, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE),
            false).show();
}
项目:android-app-common-tasks    文件:Common.java   
/**
 * show timepicker
 *
 * @param mContext
 * @param mTextView formar of the time
 * @return show timepicker
 */
public static void showTimePickerDialog(final Context mContext,
                                        final TextView mTextView) {
    new TimePickerDialog(mContext, new OnTimeSetListener() {

        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm a");
            dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dateTime.set(Calendar.MINUTE, minute);

            mTextView.setText(timeFormatter.format(dateTime.getTime()));
        }
    }, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE),
            false).show();
}
项目:sleep-battery    文件:BaseTimePickerDialog.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
    try{
        mListener = (TimePickerDialogInteraction)getActivity();
    }
    catch (ClassCastException e){
        throw new ClassCastException(getActivity().toString()
            + " must implement TimePickerDialogInteraction");
    }
    Time setTime = getTimeFromSetting();
    return new TimePickerDialog(
            getActivity(),
            this,
            setTime.getHour(),
            setTime.getMinute(),
            false);
}
项目:GallyShuttle    文件:ScheduleActivity.java   
@Subscribe
public void setAlarm(OnAlarmClickEvent event) {
    arrivalTime = event.arrivalTime;
    alarmTime = event.arrivalTime;
    int reminder = Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_key_alarm_reminder), "5"));
    alarmTime = alarmTime.minusMinutes(reminder);

    TimePickerDialog timePickerDialog = new TimePickerDialog(
            this,
            this,
            alarmTime.getHourOfDay(),
            alarmTime.getMinuteOfHour(),
            DateFormat.is24HourFormat(this)
    );
    timePickerDialog.setTitle(R.string.alarm_dialog_title);
    timePickerDialog.setMessage(getString(R.string.alarm_dialog_message_fmt, DateUtils.formatTime(arrivalTime)));
    timePickerDialog.show();
}
项目:foheart    文件:DateTimePicker.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);

    if (this.hour >-1 && this.minute >-1)
    {
        hour = this.hour;
        minute = this.minute;
    }

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


}
项目:countdown-for-dashclock    文件:BaseExtensionSettings.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());


    int hour, minute;
    final Calendar c = Calendar.getInstance();
    // If no date has been chosen, use the current date
    if (prefs.getInt(baseExtensionSettings.getPrefTimeHour(), -5) == -5) {
        hour = c.get(Calendar.HOUR_OF_DAY);
        minute = c.get(Calendar.MINUTE);
    } else {
        hour = prefs.getInt(baseExtensionSettings.getPrefTimeHour(), c.get(Calendar.HOUR_OF_DAY));
        minute = prefs.getInt(baseExtensionSettings.getPrefTimeMinute(), c.get(Calendar.MINUTE));
    }

    // Create a new instance of TimePickerDialog
    return new TimePickerDialog(getActivity(), this, hour, minute,
            DateFormat.is24HourFormat(getActivity()));
}
项目:gearshift    文件:TimePickerFragment.java   
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();

    int hour, minute;

    if (getArguments().containsKey(ARG_HOUR)) {
        hour = getArguments().getInt(ARG_HOUR);
        c.set(Calendar.HOUR_OF_DAY, hour);
    } else {
        hour = c.get(Calendar.HOUR_OF_DAY);
    }

    if (getArguments().containsKey(ARG_MINUTE)) {
        minute = getArguments().getInt(ARG_MINUTE);
        c.set(Calendar.MINUTE, minute);
    } else {
        minute = c.get(Calendar.MINUTE);
    }

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute,
        DateFormat.is24HourFormat(getActivity()));
}
项目:timetracker    文件:EditRecordingActivity.java   
public void showTimePickerStop(View view) {
    final Calendar cal = calEnd;
    TimePickerDialog dialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker picker, int hourOfDay, int minute) {
            cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
            cal.set(Calendar.MINUTE, minute);

            //check consistency: recording's end after start?
            if (!calEnd.after(calStart)) {
                // reset start to a time just before end
                calStart.setTime(calEnd.getTime());
                calStart.add(Calendar.MINUTE, -1); //time was changed, so difference will be 1 minute

                //TODO: somehow highlight the changed start time?
            }

            updateTimeViews();
        }
    }, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
    dialog.show();
}
项目:openvidonn    文件:AlarmArrayAdapter.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle bundle = this.getArguments();
    if(bundle.containsKey(TIMEPICKER_ALARM)) {
        this.alarm = (Alarm) bundle.getParcelable(TIMEPICKER_ALARM);
    } else {
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);
        this.alarm = new Alarm(hour, minute, (byte) 0, false, (byte) 0, 0);
    }

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, alarm.getHour(), alarm.getMinutes(),
            DateFormat.is24HourFormat(getActivity()));
}
项目:schedule-alarm-manager    文件:ScheduleTestActivity.java   
private void selectTime(final View view) {
    // Launch the timepreference
    // Set the view with the time.

    Toast.makeText(this, "Clicked time", Toast.LENGTH_SHORT).show();

    TimePickerDialog.OnTimeSetListener timeSetListener = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hour, int minute) {
            Calendar tempTime = convertToCalendar(hour, minute);
            setTextAndTagOnTimeView(view, tempTime);
        }
    };

    Calendar time = (Calendar)view.getTag();
    TimePickerDialog tpDialog =
            new TimePickerDialog(this,
                                 timeSetListener,
                                 time.get(Calendar.HOUR_OF_DAY),
                                 time.get(Calendar.MINUTE),
                                 false);
    tpDialog.show();
}
项目:silent-meeting    文件:TimePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    TextView textView = new TextView(getActivity().getApplicationContext());
    textView.setText("Set Time");
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20f);
    textView.setPadding(20, 20, 20, 20);

    final TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), this, 0, 0, true);
    timePickerDialog.setCustomTitle(textView);

    String setting = getArguments().getString(SETTING);
    if (isBlank(setting)) {
        throw new IllegalArgumentException("Setting must be provided");
    }

    long time = Setting.getLong(getActivity().getApplicationContext(), setting);
    time = time / 1000 / 60;
    int hour = (int) time / 60;
    int minute = (int) time % 60;
    timePickerDialog.updateTime(hour, minute);

    return timePickerDialog;
}
项目:AgWeatherNet    文件:SingleAlertFragment.java   
private void setEventListeners() {
    saveAlert.setOnClickListener(onAlertSave());
    alertEventSpinner.setOnItemSelectedListener(spinnerItemSelected());
    editStartTime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TimePickerDialog tp1 = new TimePickerDialog(activity,
                    new OnTimeSetListener() {

                        @Override
                        public void onTimeSet(TimePicker view,
                                int hourOfDay, int minute) {
                            editStartTime.setText(hourOfDay + ":" + minute);
                        }
                    }, 00, 00, true);
            tp1.show();
        }
    });
}
项目:TimerViews    文件:CountDownTimersActivity.java   
private void setCountDownTime(final CountDownTimerView countDownTimerView)
{
    TimePickerDialog timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener()
    {
        //hours are taken as minutes and minutes as seconds
        @Override
        public void onTimeSet(TimePicker view, int minute, int second)
        {
            long countDownMillis = (minute * 60 + second) * 1000;
            countDownTimerView.setCountDownTime(countDownMillis);
        }
    }, 0, 0, true);
    timePickerDialog.setTitle(getString(R.string.minutes_and_seconds));

    timePickerDialog.show();
}