/**
   * Called when the user clicks on a day. Handles callbacks to the {@link OnDayClickListener} if
   * one is set.
   *
   * <p>If the day is out of the range set by minDate and/or maxDate, this is a no-op.
   *
   * @param day The day that was clicked
   */
  private void onDayClick(int day) {
    // If the min / max date are set, only process the click if it's a valid selection.
    if (isOutOfRange(mYear, mMonth, day)) {
      return;
    }

    if (mOnDayClickListener != null) {
      mOnDayClickListener.onDayClick(this, new CalendarDay(mYear, mMonth, day));
    }

    // This is a no-op if accessibility is turned off.
    mTouchHelper.sendEventForVirtualView(day, AccessibilityEvent.TYPE_VIEW_CLICKED);
  }
コード例 #2
0
  /**
   * Called when the user clicks on a day. Handles callbacks to the {@link OnDayClickListener} if
   * one is set.
   *
   * @param day the day that was clicked
   */
  private boolean onDayClicked(int day) {
    if (!isValidDayOfMonth(day) || !isDayEnabled(day)) {
      return false;
    }

    if (mOnDayClickListener != null) {
      final Calendar date = Calendar.getInstance();
      date.set(mYear, mMonth, day);
      mOnDayClickListener.onDayClick(this, date);
    }

    // This is a no-op if accessibility is turned off.
    mTouchHelper.sendEventForVirtualView(day, AccessibilityEvent.TYPE_VIEW_CLICKED);
    return true;
  }