/**
   * Set either minutes or hours as showing.
   *
   * @param animate True to animate the transition, false to show with no animation.
   */
  public void setCurrentItemShowing(int index, boolean animate) {
    if (index != HOUR_INDEX && index != MINUTE_INDEX) {
      Log.e(TAG, "TimePicker does not support view at index " + index);
      return;
    }

    int lastIndex = getCurrentItemShowing();
    mCurrentItemShowing = index;

    if (animate && (index != lastIndex)) {
      List<ObjectAnimator> anims = new ArrayList<ObjectAnimator>();
      if (index == MINUTE_INDEX) {
        anims.addAll(mHourRadialTextsView.getDisappearAnimator());
        anims.addAll(mHourRadialSelectorView.getDisappearAnimator());
        anims.addAll(mMinuteRadialTextsView.getReappearAnimator());
        anims.addAll(mMinuteRadialSelectorView.getReappearAnimator());
      } else if (index == HOUR_INDEX) {
        anims.addAll(mHourRadialTextsView.getReappearAnimator());
        anims.addAll(mHourRadialSelectorView.getReappearAnimator());
        anims.addAll(mMinuteRadialTextsView.getDisappearAnimator());
        anims.addAll(mMinuteRadialSelectorView.getDisappearAnimator());
      }

      if (mTransition != null && mTransition.isRunning()) {
        mTransition.end();
      }
      mTransition = new AnimatorSet();
      mTransition.playTogether(anims.toArray(new ObjectAnimator[anims.size()]));
      mTransition.start();
    } else {
      int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
      int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
      Log.i(
          TAG,
          "set current item showing, no animate, hour alpha:"
              + hourAlpha
              + ", min alpha:"
              + minuteAlpha);
      ViewHelper.setAlpha(mHourRadialTextsView, hourAlpha);
      ViewHelper.setAlpha(mHourRadialSelectorView, hourAlpha);
      ViewHelper.setAlpha(mMinuteRadialTextsView, minuteAlpha);
      ViewHelper.setAlpha(mMinuteRadialSelectorView, minuteAlpha);
    }
  }
Пример #2
0
  /**
   * Set either minutes or hours as showing.
   *
   * @param animate True to animate the transition, false to show with no animation.
   */
  public void setCurrentItemShowing(int index, boolean animate) {
    if (index != HOUR_INDEX && index != MINUTE_INDEX) {
      Log.e(TAG, "TimePicker does not support view at index " + index);
      return;
    }

    int lastIndex = getCurrentItemShowing();
    mCurrentItemShowing = index;

    if (animate && (index != lastIndex)) {
      ObjectAnimator[] anims = new ObjectAnimator[4];
      if (index == MINUTE_INDEX) {
        anims[0] = mHourRadialTextsView.getDisappearAnimator();
        anims[1] = mHourRadialSelectorView.getDisappearAnimator();
        anims[2] = mMinuteRadialTextsView.getReappearAnimator();
        anims[3] = mMinuteRadialSelectorView.getReappearAnimator();
      } else if (index == HOUR_INDEX) {
        anims[0] = mHourRadialTextsView.getReappearAnimator();
        anims[1] = mHourRadialSelectorView.getReappearAnimator();
        anims[2] = mMinuteRadialTextsView.getDisappearAnimator();
        anims[3] = mMinuteRadialSelectorView.getDisappearAnimator();
      }

      if (mTransition != null && mTransition.isRunning()) {
        mTransition.end();
      }
      mTransition = new AnimatorSet();
      mTransition.playTogether(anims);
      mTransition.start();
    } else {
      int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
      int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
      mHourRadialTextsView.setAlpha(hourAlpha);
      mHourRadialSelectorView.setAlpha(hourAlpha);
      mMinuteRadialTextsView.setAlpha(minuteAlpha);
      mMinuteRadialSelectorView.setAlpha(minuteAlpha);
    }
  }