本文整理汇总了Java中com.wdullaer.materialdatetimepicker.time.TimePickerDialog类的典型用法代码示例。如果您正苦于以下问题:Java TimePickerDialog类的具体用法?Java TimePickerDialog怎么用?Java TimePickerDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimePickerDialog类属于com.wdullaer.materialdatetimepicker.time包,在下文中一共展示了TimePickerDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
if (view == sunrisePicker) {
hrsSunrise = hourOfDay;
minSunrise = minute;
sunriseTime.setText(String.format(Locale.getDefault(), "%1$02d:%2$02d", hrsSunrise, minSunrise));
mSettings.putInt(AppSetting.KEY_HOURS_STOP, hrsSunrise);
mSettings.putInt(AppSetting.KEY_MINUTES_STOP, minSunrise);
} else if (view == sunsetPicker) {
hrsSunset = hourOfDay;
minSunset = minute;
sunsetTime.setText(String.format(Locale.getDefault(), "%1$02d:%2$02d", hrsSunset, minSunset));
mSettings.putInt(AppSetting.KEY_HOURS_START, hrsSunset);
mSettings.putInt(AppSetting.KEY_MINUTES_START, minSunset);
}
Utility.updateAlarmSettings(getContext());
}
示例2: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
// if date is not chosen first but time is chosen -> make today the default date.
// also check for valid time, must be today but not the past hour or minutes.
if (date.equals(dateTimeUtils.fillDateIfEmpty("")) && dateTimeUtils.checkInvalidTime(hourOfDay, minute)) {
AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
alertDialog.setTitle("Time not valid!");
alertDialog.setMessage("You are selecting a point of time in the past!");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
return;
}
// set time value and update text
time = dateTimeUtils.timeToString(hourOfDay, minute);
reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
示例3: createDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
/**
* Creates a {@link TimePickerDialog} instance.
*
* @param context to retrieve the time format (12 or 24 hour)
* @param localTime the initial localTime
* @param listener to listen for a localTime selection
* @param clock to retrieve the calendar from
* @return a new instance of {@link TimePickerDialog}
*/
@NonNull
public static TimePickerDialog createDialog(@NonNull Context context, @Nullable LocalTime localTime,
@Nullable Consumer<LocalTime> listener, @NonNull Clock clock) {
TimePickerDialog.OnTimeSetListener dialogCallBack = (view, hourOfDay, minute, second) -> {
LocalTime time = LocalTime.of(hourOfDay, minute, second);
Optional.ofNullable(listener)
.ifPresent(theListener -> theListener.accept(time));
};
localTime = Optional.ofNullable(localTime)
.orElse(LocalTime.now(clock));
TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(
dialogCallBack,
localTime.getHour(),
localTime.getMinute(),
localTime.getSecond(),
DateFormat.is24HourFormat(context)
);
timePickerDialog.dismissOnPause(true);
return timePickerDialog;
}
示例4: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
if (view == sunrisePicker) {
hrsSunrise = hourOfDay;
minSunrise = minute;
sunriseTime.setText(String.format(Locale.getDefault(),
"%1$02d:%2$02d", hrsSunrise, minSunrise));
mSettings.putInt(Settings.KEY_HOURS_SUNRISE, hrsSunrise);
mSettings.putInt(Settings.KEY_MINUTES_SUNRISE, minSunrise);
} else if (view == sunsetPicker) {
hrsSunset = hourOfDay;
minSunset = minute;
sunsetTime.setText(String.format(Locale.getDefault(),
"%1$02d:%2$02d", hrsSunset, minSunset));
mSettings.putInt(Settings.KEY_HOURS_SUNSET, hrsSunset);
mSettings.putInt(Settings.KEY_MINUTES_SUNSET, minSunset);
}
AlarmUtil.updateAlarmSettings(getContext());
}
示例5: onTimeClick
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@OnClick(com.zireck.calories.R.id.layout_time)
public void onTimeClick() {
int hourOfDay, minute;
Date currentTime = mPresenter.getCurrentTime();
if (currentTime != null) {
Calendar currentCalendar = Calendar.getInstance();
currentCalendar.setTime(currentTime);
hourOfDay = currentCalendar.get(Calendar.HOUR_OF_DAY);
minute = currentCalendar.get(Calendar.MINUTE);
} else {
Calendar now = Calendar.getInstance();
hourOfDay = now.get(Calendar.HOUR_OF_DAY);
minute = now.get(Calendar.MINUTE);
}
mTimePickerDialog = TimePickerDialog.newInstance(
this,
hourOfDay,
minute,
true
);
mTimePickerDialog.show(getActivity().getFragmentManager(), "Timepickerdialog");
}
示例6: onDateSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
mScheduledDate = Calendar.getInstance();
mScheduledDate.set(Calendar.YEAR, year);
mScheduledDate.set(Calendar.MONTH, month);
mScheduledDate.set(Calendar.DAY_OF_MONTH, day);
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
CreateActivity.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE) + 1,
false
);
tpd.show(getFragmentManager(), Consts.FRAGMENT_TAG_DATETIME_PICKER);
}
示例7: onResume
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
service.bind();
TimePickerDialog tpd = (TimePickerDialog) getFragmentManager().
findFragmentByTag("TimePickerDialog");
if (tpd != null) {
picker = tpd;
tpd.setOnTimeSetListener(this);
tpd.setOnTimeChangedListener(this);
}
}
示例8: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int h, int min) {
if (nightTimeStart[0] >= 25) {
nightTimeStart = new int[]{h, min};
boolean twentyFourHourStyle = DateFormat.is24HourFormat(getActivity());
TimePickerDialog tpd = TimePickerDialog
.newInstance(this, 6, 0, twentyFourHourStyle);
tpd.setOnCancelListener(this);
tpd.setTitle(getActivity().getString(R.string.nighttime_end_dialog_title));
tpd.show(getFragmentManager(), NIGHT_END_TIME_DIALOG_TAG);
} else {
SharedPreferences current = getActivity().getSharedPreferences("night_time", Context.MODE_PRIVATE);
current.edit().putInt("startHour", nightTimeStart[0])
.putInt("startMinute", nightTimeStart[1])
.putInt("endHour", h)
.putInt("endMinute", min)
.apply();
nightTimeStart[0] = 42;
}
}
示例9: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
String hour = hourOfDay >= 10 ? "" + hourOfDay : "0" + hourOfDay;
String min = minute >= 10 ? "" + minute : "0" + minute;
mEditRemindTime.setText(hour + ":" + min);
timeText = mEditRemindTime.getText().toString();
}
示例10: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
String hour = hourOfDay >= 10 ? "" + hourOfDay : "0" + hourOfDay;
String min = minute >= 10 ? "" + minute : "0" + minute;
mEditAccountTime.setText(hour + ":" + min);
String date = mEditAccountDate.getText().toString();
String time = mEditAccountTime.getText().toString();
account.setRdate(TimeUtils.parseDateTime(date + " " + time));
}
示例11: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
String hour = hourOfDay >= 10 ? "" + hourOfDay : "0" + hourOfDay;
String min = minute >= 10 ? "" + minute : "0" + minute;
mEditAlarmTime.setText(hour + ":" + min);
alarmTime = mEditAlarmTime.getText().toString();
}
示例12: onTimeSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
mObservable.notifyObservers(true);
String hour = hourOfDay >= 10 ? "" + hourOfDay : "0" + hourOfDay;
String min = minute >= 10 ? "" + minute : "0" + minute;
mEditAccountTime.setText(hour + ":" + min);
}
示例13: setTime
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
public void setTime(View v){
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
false
);
tpd.setThemeDark(false);
tpd.show(getFragmentManager(), "Timepickerdialog");
}
示例14: showTimeDelayDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
private void showTimeDelayDialog() {
int totalSecs = preferences.getTimerDelay();
int hours = totalSecs / 3600;
int minutes = (totalSecs % 3600) / 60;
int seconds = totalSecs % 60;
TimePickerDialog mTimePickerDialog = TimePickerDialog.newInstance(this, hours, minutes, seconds, true);
mTimePickerDialog.enableSeconds(true);
mTimePickerDialog.show(mActivity.getFragmentManager(), "TimePickerDialog");
}
示例15: showTimeDelayDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入依赖的package包/类
private void showTimeDelayDialog() {
int totalSecs = preferences.getTimerDelay();
int hours = totalSecs / 3600;
int minutes = (totalSecs % 3600) / 60;
int seconds = totalSecs % 60;
TimePickerDialog mTimePickerDialog = TimePickerDialog.newInstance(this, hours, minutes, seconds, true);
mTimePickerDialog.enableSeconds(true);
mTimePickerDialog.show(getFragmentManager(), "TimePickerDialog");
}