コード例 #1
0
  @Override
  public void save() {
    DayValues dayValues = null;

    if (mListener != null) {
      switch (mCurrentValues.type) {
        case DayValues.TYPE_ONE_SHOT:
          Calendar calendar = Calendar.getInstance();
          calendar.set(mDatePicker.getYear(), mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
          dayValues = new OneShotValues(calendar);
          break;

        case DayValues.TYPE_REPEAT:
          dayValues = new RepeatValues(mRepeatPicker.getSelectedDays(), Calendar.getInstance());
          break;

        case DayValues.TYPE_EVERY:
          dayValues =
              new IntervalValues(
                  mIntervalPicker.getUnit(),
                  mIntervalPicker.getNumberValue(),
                  Calendar.getInstance());
          break;
      }
      mCurrentValues = dayValues;
      mListener.onSchedulerDayChange(this, dayValues);
    }
  }
コード例 #2
0
        @Override
        public void onClick(View v) {
          if (mBtnOneShot == v) {
            Calendar date = Calendar.getInstance();
            date.set(mDatePicker.getYear(), mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
            mCurrentValues = new OneShotValues(date);
          } else if (mBtnRepeat == v) {
            List<Integer> days = mRepeatPicker.getSelectedDays();
            mCurrentValues = new RepeatValues(days, Calendar.getInstance());
          } else if (mBtnEvery == v) {
            mCurrentValues =
                new IntervalValues(
                    mIntervalPicker.getUnit(),
                    mIntervalPicker.getNumberValue(),
                    Calendar.getInstance());
          }

          updateViews();
          save();
        }