当前位置: 首页>>代码示例>>Java>>正文


Java TimePickerDialog类代码示例

本文整理汇总了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());
}
 
开发者ID:tranleduy2000,项目名称:screenfilter,代码行数:18,代码来源:SchedulerDialog.java

示例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);
}
 
开发者ID:LewisVo,项目名称:Minitask,代码行数:23,代码来源:AddTodoItem.java

示例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;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:31,代码来源:TimePickerDialogHelper.java

示例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());
}
 
开发者ID:fython,项目名称:Blackbulb,代码行数:20,代码来源:SchedulerDialog.java

示例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");
}
 
开发者ID:andreshj87,项目名称:CleanFit,代码行数:27,代码来源:AddMealFragment.java

示例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);
}
 
开发者ID:jordond,项目名称:hooold,代码行数:17,代码来源:CreateActivity.java

示例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);
    }
}
 
开发者ID:CarloRodriguez,项目名称:AlarmOn,代码行数:17,代码来源:ActivityAlarmSettings.java

示例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;
    }
}
 
开发者ID:QuickLyric,项目名称:QuickLyric,代码行数:22,代码来源:SettingsFragment.java

示例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();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:8,代码来源:RemindActivity.java

示例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));
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:11,代码来源:AccountingActivity.java

示例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();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:8,代码来源:AlarmActivity.java

示例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);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:8,代码来源:MonthAccountAdapter.java

示例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");
}
 
开发者ID:attiqrehman1991,项目名称:Task-Reminder,代码行数:12,代码来源:ReminderEditActivity.java

示例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");
}
 
开发者ID:guardianproject,项目名称:haven,代码行数:13,代码来源:SettingsFragment.java

示例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");
}
 
开发者ID:guardianproject,项目名称:haven,代码行数:12,代码来源:MonitorActivity.java


注:本文中的com.wdullaer.materialdatetimepicker.time.TimePickerDialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。