@Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    float effectOffset = isSmall(positionOffset) ? 0 : positionOffset;

    mLeft = findViewFromObject(position);
    mRight = findViewFromObject(position + 1);

    animateStack(mLeft, mRight, effectOffset, positionOffsetPixels);
    super.onPageScrolled(position, positionOffset, positionOffsetPixels);
  }
Exemple #2
0
  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    appData.put("CURR_FRAGMENT", getCurrentItem());
    // 滑动特别小的距离时,我们认为没有动,可有可无的判断
    float effectOffset = isSmall(positionOffset) ? 0 : positionOffset;

    mLeft = findViewFromObject(position);
    mRight = findViewFromObject(position + 1);
    //		animateStack(mLeft, mRight, effectOffset, positionOffsetPixels);
    if (mContext instanceof MainActivity) ((MainActivity) mContext).setPageDot(getCurrentItem());

    super.onPageScrolled(position, positionOffset, positionOffsetPixels);
  }
Exemple #3
0
  /**
   * android4.1+设置PageTransformer会使ViewPager的子页里面的触摸事件异常 (当前看到的子页并非在最上面,所以触摸事件被隐藏在其上面的View给消费了)
   * 所以结合setPageTransformer(),在onPageScrolled()里“手动”调用切换页面的动画
   */
  @Override
  protected void onPageScrolled(int position, float offset, int offsetPixels) {
    super.onPageScrolled(position, offset, offsetPixels);
    // 下面的源码来自super.onPageScrolled()
    int scrollX;
    int childCount;
    int i;
    if (this.mPageTransformer != null) {
      scrollX = this.getScrollX();
      childCount = this.getChildCount();

      for (i = 0; i < childCount; ++i) {
        View var15 = this.getChildAt(i);
        ViewPager.LayoutParams var16 = (ViewPager.LayoutParams) var15.getLayoutParams();
        if (!var16.isDecor) {
          float var17 = (float) (var15.getLeft() - scrollX) / (float) this.getClientWidth();
          this.mPageTransformer.transformPage(var15, var17);
        }
      }
    }
  }
  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    if (mState == State.IDLE && positionOffset > 0) {
      oldPage = getCurrentItem();
      mState = position == oldPage ? State.GOING_RIGHT : State.GOING_LEFT;
    }
    boolean goingRight = position == oldPage;
    if (mState == State.GOING_RIGHT && !goingRight) mState = State.GOING_LEFT;
    else if (mState == State.GOING_LEFT && goingRight) mState = State.GOING_RIGHT;

    float effectOffset = isSmall(positionOffset) ? 0 : positionOffset;

    //		mLeft = getChildAt(position);
    //		mRight = getChildAt(position+1);
    mLeft = findViewFromObject(position);
    mRight = findViewFromObject(position + 1);

    if (mFadeEnabled) animateFade(mLeft, mRight, effectOffset);
    if (mOutlineEnabled) animateOutline(mLeft, mRight);

    switch (mEffect) {
      case Standard:
        break;
      case Tablet:
        animateTablet(mLeft, mRight, effectOffset);
        break;
      case CubeIn:
        animateCube(mLeft, mRight, effectOffset, true);
        break;
      case CubeOut:
        animateCube(mLeft, mRight, effectOffset, false);
        break;
      case FlipVertical:
        animateFlipVertical(mLeft, mRight, positionOffset, positionOffsetPixels);
        break;
      case FlipHorizontal:
        animateFlipHorizontal(mLeft, mRight, effectOffset, positionOffsetPixels);
      case Stack:
        animateStack(mLeft, mRight, effectOffset, positionOffsetPixels);
        break;
      case ZoomIn:
        animateZoom(mLeft, mRight, effectOffset, true);
        break;
      case ZoomOut:
        animateZoom(mLeft, mRight, effectOffset, false);
        break;
      case RotateUp:
        animateRotate(mLeft, mRight, effectOffset, true);
        break;
      case RotateDown:
        animateRotate(mLeft, mRight, effectOffset, false);
        break;
      case Accordion:
        animateAccordion(mLeft, mRight, effectOffset);
        break;
    }

    super.onPageScrolled(position, positionOffset, positionOffsetPixels);

    if (effectOffset == 0) {
      disableHardwareLayer();
      mState = State.IDLE;
    }
  }