/**
   * Set either minutes or hours as showing.
   *
   * @param animate True to animate the transition, false to show with no animation.
   */
  @SuppressLint("NewApi")
  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;
    }

    // NineOldDroids does not work in this case due to denepency recursion.
    animate = animate && Build.VERSION.SDK_INT >= 14;

    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 {
      if (Build.VERSION.SDK_INT >= 11) {
        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);
      } else {
        int hourVisibility = (index == HOUR_INDEX) ? View.VISIBLE : View.INVISIBLE;
        int minuteVisibility = (index == MINUTE_INDEX) ? View.VISIBLE : View.INVISIBLE;
        mHourRadialTextsView.setVisibility(hourVisibility);
        mHourRadialSelectorView.setVisibility(hourVisibility);
        mMinuteRadialTextsView.setVisibility(minuteVisibility);
        mMinuteRadialSelectorView.setVisibility(minuteVisibility);
      }
    }
  }