コード例 #1
0
  @Override
  public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);

    config.setCountdownTimestamp(calendar.getTimeInMillis());
    tpd.setCloseOnSingleTapMinute(false);
    tpd.show(getFragmentManager(), TAG);
    tvCountdown.setTime(config.getCountdownTimestamp());
  }
コード例 #2
0
ファイル: AutoOnOffView.java プロジェクト: xiaouC/AM
  AutoOnOffView() {
    is_pick_start_time = true;

    Calendar calendar = Calendar.getInstance();
    timePickerDialog =
        TimePickerDialog.newInstance(
            this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, false);

    TimePickerDialog tpd =
        (TimePickerDialog)
            main_activity.getSupportFragmentManager().findFragmentByTag(TIMEPICKER_TAG);
    if (tpd != null) tpd.setOnTimeSetListener(this);
  }
コード例 #3
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.tv_enable:
        config.setWidgetCountdownEnable(true);
        getActivity().finish();
        break;
      case R.id.tv_disable:
        config.setWidgetCountdownEnable(false);
        getActivity().finish();
        break;
      case R.id.tv_countdown_content:
        Intent intent = new Intent(getActivity(), CommentActivity.class);
        intent.putExtra(Constants.StringConstant.PARAMS_DATA, config.getCountdownContent());
        intent.putExtra(Constants.StringConstant.PARAMS_DATA1, config.getWidgetCountdownColor());
        startActivityForResult(intent, Constants.RequestCode.REQUEST_CODE_CHAGE_TEXT_TITLE);
        break;
      case R.id.tv_countdown_time:
        calendar.setTimeInMillis(config.getCountdownTimestamp());
        dpd =
            DatePickerDialog.newInstance(
                this,
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                false);
        tpd =
            TimePickerDialog.newInstance(
                this,
                calendar.get(Calendar.HOUR_OF_DAY),
                calendar.get(Calendar.MINUTE),
                false,
                false);

        dpd.setYearRange(Constants.CommonValue.FIRST_YEAR, Constants.CommonValue.LAST_YEAR);
        dpd.setCloseOnSingleTapDay(false);
        dpd.show(getFragmentManager(), TAG);
        break;
      default:
        break;
    }
  }
コード例 #4
0
  /** @param id */
  protected boolean onItemSelected(int id) {
    Bundle args;
    boolean consumed = false;
    Calendar calendar = null;
    switch (id) {
      case Statics.ITEM_SAVE:
        saveTimer();
        consumed = true;
        break;

      case Statics.ITEM_CANCEL:
        finish(Activity.RESULT_CANCELED);
        consumed = true;
        break;

      case Statics.ITEM_PICK_SERVICE:
        pickService();
        consumed = true;
        break;

      case Statics.ITEM_PICK_BEGIN_DATE:
        calendar = getCalendar(mBegin);
        DatePickerDialog datePickerDialogBegin =
            DatePickerDialog.newInstance(
                new DatePickerDialog.OnDateSetListener() {
                  @Override
                  public void onDateSet(
                      DatePickerDialog datePickerDialog, int year, int month, int day) {
                    TimerEditFragment.this.onDateSet(true, year, month, day);
                  }
                },
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                true);
        getMultiPaneHandler().showDialogFragment(datePickerDialogBegin, "dialog_pick_begin_date");
        consumed = true;
        break;

      case Statics.ITEM_PICK_BEGIN_TIME:
        calendar = getCalendar(mBegin);
        TimePickerDialog timePickerDialogBegin =
            TimePickerDialog.newInstance(
                new TimePickerDialog.OnTimeSetListener() {
                  @Override
                  public void onTimeSet(
                      RadialPickerLayout radialPickerLayout, int hour, int minute) {
                    TimerEditFragment.this.onTimeSet(true, hour, minute);
                  }
                },
                calendar.get(Calendar.HOUR_OF_DAY),
                calendar.get(Calendar.MINUTE),
                true,
                true);
        getMultiPaneHandler().showDialogFragment(timePickerDialogBegin, "dialog_pick_begin_time");
        consumed = true;
        break;

      case Statics.ITEM_PICK_END_DATE:
        calendar = getCalendar(mEnd);
        DatePickerDialog datePickerDialogEnd =
            DatePickerDialog.newInstance(
                new DatePickerDialog.OnDateSetListener() {
                  @Override
                  public void onDateSet(
                      DatePickerDialog datePickerDialog, int year, int month, int day) {
                    TimerEditFragment.this.onDateSet(false, year, month, day);
                  }
                },
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                true);
        getMultiPaneHandler().showDialogFragment(datePickerDialogEnd, "dialog_pick_end_date");
        consumed = true;
        break;

      case Statics.ITEM_PICK_END_TIME:
        calendar = getCalendar(mEnd);
        TimePickerDialog timePickerDialogEnd =
            TimePickerDialog.newInstance(
                new TimePickerDialog.OnTimeSetListener() {
                  @Override
                  public void onTimeSet(
                      RadialPickerLayout radialPickerLayout, int hour, int minute) {
                    TimerEditFragment.this.onTimeSet(false, hour, minute);
                  }
                },
                calendar.get(Calendar.HOUR_OF_DAY),
                calendar.get(Calendar.MINUTE),
                true,
                true);
        getMultiPaneHandler().showDialogFragment(timePickerDialogEnd, "dialog_pick_end_time");
        consumed = true;
        break;

      case Statics.ITEM_PICK_REPEATED:
        pickRepeatings();
        consumed = true;
        break;

      case Statics.ITEM_PICK_TAGS:
        pickTags();
        consumed = true;
        break;

      default:
        consumed = super.onItemSelected(id);
        break;
    }

    return consumed;
  }