本文整理汇总了Java中com.wdullaer.materialdatetimepicker.time.TimePickerDialog.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java TimePickerDialog.newInstance方法的具体用法?Java TimePickerDialog.newInstance怎么用?Java TimePickerDialog.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.wdullaer.materialdatetimepicker.time.TimePickerDialog
的用法示例。
在下文中一共展示了TimePickerDialog.newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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");
}
示例3: 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);
}
示例4: 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;
}
}
示例5: 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");
}
示例6: 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");
}
示例7: 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");
}
示例8: showTimePickerDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
private void showTimePickerDialog() {
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(this.timeSetListener, now.get(11),
now.get(12), true);
tpd.vibrate(false);
tpd.setAccentColor(getResources().getColor(R.color.gn));
tpd.show(getFragmentManager(), "Timepickerdialog");
}
示例9: onDateSet
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
String date = " " + year + "年\n" + (++monthOfYear) + "月" + dayOfMonth+"日";
if (left) {
naiveDateLeft = new NaiveDate(year, monthOfYear, dayOfMonth);
leftDate = date;
} else {
naiveDateRight = new NaiveDate(year, monthOfYear, dayOfMonth);
rightDate = date;
}
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
PublishNeedsActivity.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
true
);
tpd.enableSeconds(false);
tpd.setThemeDark(false);
tpd.vibrate(true);
tpd.dismissOnPause(true);
tpd.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Log.d("TimePicker", "Dialog was cancelled");
}
});
tpd.show(getFragmentManager(), "Timepickerdialog");
}
示例10: updateCountdownTime
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
@OnClick(R.id.countdown_time)
public void updateCountdownTime() {
Calendar cal = Calendar.getInstance();
cal.setTime(dateOption.getDate());
TimePickerDialog dpd = TimePickerDialog.newInstance(
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
Calendar curDate = Calendar.getInstance();
curDate.setTime(dateOption.getDate());
curDate.set(curDate.get(Calendar.YEAR), curDate.get(Calendar.MONTH), curDate.get(Calendar.DAY_OF_MONTH), hourOfDay, minute, second);
dateOption.setValue(curDate.getTime());
dateOption.save();
updateWidgetProperty(COUNTDOWN_DATE, dateOption.value);
updateCountdownDateAndTimeText();
}
},
cal.get(Calendar.HOUR_OF_DAY),
cal.get(Calendar.MINUTE),
false
);
dpd.show(getActivity().getFragmentManager(), "timepickerdialog");
}
示例11: openTimePicker
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
private void openTimePicker() {
Calendar c = Calendar.getInstance();
long time = mRemindItem.getTime();
if (time > 0) {
c.setTimeInMillis(time);
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(mTimeSetListener, hour, minute, true);
// timePickerDialog.dismissOnPause(true);
timePickerDialog.vibrate(false);
timePickerDialog.show(getActivity().getFragmentManager(), TIME_PICKER_DIALOG_TAG);
}
示例12: sleeping
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
public void sleeping(){
if(IS_ALARM_CREATED){
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);
builder.setTitle(getResources().getString(R.string.autocomplete));
builder.setMessage(getResources().getString(R.string.mess_to_stop_alarm));
builder.setNegativeButton(getResources().getString(R.string.cancel),null);
builder.setPositiveButton(getResources().getString(R.string.close_alarm),new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
alarm.cancel(startAlarmPI);
IS_ALARM_CREATED=false;
createToast(getResources().getString(R.string.mess_alarm_closed));
}
});
builder.setCancelable(false);
builder.show();
}else {
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(this, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), true);
if(settings.getInt(5)==1) {
tpd.setThemeDark(true);
}else{
tpd.setThemeDark(false);
}
tpd.setTitle(getResources().getString(R.string.autocomplete));
tpd.setCancelText(getResources().getString(R.string.cancel));
tpd.setOkText(getResources().getString(R.string.alarm_ok));
tpd.show(getFragmentManager(), "TimePicker");
Log.d("State", "MainActivity: sleeping()");
}
}
示例13: onClick
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(eventTime);
switch (view.getId()) {
case R.id.careportal_newnstreatment_eventdate:
DatePickerDialog dpd = DatePickerDialog.newInstance(
this,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)
);
dpd.setThemeDark(true);
dpd.dismissOnPause(true);
dpd.show(context.getFragmentManager(), "Datepickerdialog");
break;
case R.id.careportal_newnstreatment_eventtime:
TimePickerDialog tpd = TimePickerDialog.newInstance(
this,
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE),
DateFormat.is24HourFormat(context)
);
tpd.setThemeDark(true);
tpd.dismissOnPause(true);
tpd.show(context.getFragmentManager(), "Timepickerdialog");
break;
case R.id.ok:
createNSTreatment();
dismiss();
break;
case R.id.cancel:
dismiss();
break;
}
}
示例14: showTimeDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
/**
* 时间选择
*/
private void showTimeDialog() {
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
ActReleaseProductActivity.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
true
);
tpd.show(getFragmentManager(), "Timepickerdialog");
}
示例15: showTimeDialog
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; //导入方法依赖的package包/类
private void showTimeDialog() {
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(
ActReleaseRoadshowActivity.this,
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
true
);
tpd.show(getFragmentManager(), "Timepickerdialog");
}