コード例 #1
0
 private void animateChangeImpl(DefaultItemAnimator.ChangeInfo paramChangeInfo)
 {
   View localView = null;
   Object localObject = oldHolder;
   if (localObject == null) {}
   for (localObject = null;; localObject = itemView)
   {
     RecyclerView.ViewHolder localViewHolder = newHolder;
     if (localViewHolder != null) {
       localView = itemView;
     }
     if (localObject != null)
     {
       localObject = ViewCompat.animate((View)localObject).setDuration(getChangeDuration());
       mChangeAnimations.add(oldHolder);
       ((ViewPropertyAnimatorCompat)localObject).translationX(toX - fromX);
       ((ViewPropertyAnimatorCompat)localObject).translationY(toY - fromY);
       ((ViewPropertyAnimatorCompat)localObject).alpha(0.0F).setListener(new DefaultItemAnimator.7(this, paramChangeInfo, (ViewPropertyAnimatorCompat)localObject)).start();
     }
     if (localView != null)
     {
       localObject = ViewCompat.animate(localView);
       mChangeAnimations.add(newHolder);
       ((ViewPropertyAnimatorCompat)localObject).translationX(0.0F).translationY(0.0F).setDuration(getChangeDuration()).alpha(1.0F).setListener(new DefaultItemAnimator.8(this, paramChangeInfo, (ViewPropertyAnimatorCompat)localObject, localView)).start();
     }
     return;
   }
 }
コード例 #2
0
  private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    mAddAnimations.add(holder);
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation
        .alpha(1)
        .setDuration(getAddDuration())
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchAddStarting(holder);
              }

              @Override
              public void onAnimationCancel(View view) {
                ViewCompat.setAlpha(view, 1);
              }

              @Override
              public void onAnimationEnd(View view) {
                animation.setListener(null);
                dispatchAddFinished(holder);
                mAddAnimations.remove(holder);
                dispatchFinishedWhenDone();
              }
            })
        .start();
  }
コード例 #3
0
    @Override
    public void onAnimationEnd(View view) {
      mAnimator.setListener(null);
      // [WORKAROUND]
      // Issue 189686: NPE can be occurred when using the ViewPropertyAnimatorCompat
      // https://code.google.com/p/android/issues/detail?id=189686
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        InternalHelperKK.clearViewPropertyAnimatorUpdateListener(view);
      } else {
        mAnimator.setUpdateListener(null);
      }

      ViewCompat.setTranslationX(view, mToX);
      ViewCompat.setTranslationY(view, mToY);

      mActive.remove(mViewHolder);

      // [WORKAROUND]
      // issue #152 - bug:Samsung S3 4.1.1(Genymotion) with swipe left
      ViewParent itemParentView = mViewHolder.itemView.getParent();
      if (itemParentView != null) {
        ViewCompat.postInvalidateOnAnimation((View) itemParentView);
      }

      if (mSwipeFinish != null) {
        mSwipeFinish.resultAction.slideAnimationEnd();
      }

      // clean up
      mActive = null;
      mAnimator = null;
      mViewHolder = null;
      mAdapter = null;
    }
コード例 #4
0
  protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    this.mAddAnimations.add(holder);
    animation
        .alpha(1.0F)
        .setDuration(this.getAddDuration())
        .setListener(
            new VpaListenerAdapter() {
              public void onAnimationStart(View view) {
                dispatchAddStarting(holder);
              }

              public void onAnimationCancel(View view) {
                ViewCompat.setAlpha(view, 1.0F);
              }

              public void onAnimationEnd(View view) {
                animation.setListener((ViewPropertyAnimatorListener) null);
                dispatchAddFinished(holder);
                mAddAnimations.remove(holder);
                dispatchFinishedWhenDone();
              }
            })
        .start();
  }
コード例 #5
0
  private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);
    float startX, startY;

    int position = (int) view.getTag();

    if (position % 2 == 0) {
      startY = -100;
      startX = -width;
    } else {
      startY = 100;
      startX = width;
    }
    Log.d("test", String.valueOf(holder.getLayoutPosition()));
    ViewCompat.setTranslationX(view, startX);
    // 应该是相对偏移
    ViewCompat.setTranslationY(view, startY);
    ViewCompat.setAlpha(view, 0);
    animation.setInterpolator(new OvershootInterpolator());
    animation
        .alpha(1)
        .translationX(0)
        .translationY(0)
        .setDuration(getAddDuration())
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchAddStarting(holder);
              }

              @Override
              public void onAnimationCancel(View view) {
                ViewCompat.setAlpha(view, 1);
              }

              @Override
              public void onAnimationEnd(View view) {
                animation.setListener(null);
                dispatchAddFinished(holder);
                mAddAnimations.remove(holder);
                dispatchFinishedWhenDone();
                // 使用这个来复原
                ViewCompat.setTranslationY(view, 0);
              }
            })
        .start();
  }
コード例 #6
0
 private void startAnimation(
     ViewPropertyAnimatorCompat viewpropertyanimatorcompat, View view) {
   Object obj = view.getTag(0x7e000000);
   Runnable runnable;
   if (obj instanceof ViewPropertyAnimatorListener) {
     obj = (ViewPropertyAnimatorListener) obj;
   } else {
     obj = null;
   }
   runnable = viewpropertyanimatorcompat.mStartAction;
   viewpropertyanimatorcompat = viewpropertyanimatorcompat.mEndAction;
   if (runnable != null) {
     runnable.run();
   }
   if (obj != null) {
     ((ViewPropertyAnimatorListener) (obj)).onAnimationStart(view);
     ((ViewPropertyAnimatorListener) (obj)).onAnimationEnd(view);
   }
   if (viewpropertyanimatorcompat != null) {
     viewpropertyanimatorcompat.run();
   }
   if (mStarterMap != null) {
     mStarterMap.remove(view);
   }
 }
コード例 #7
0
 public void withStartAction(
     ViewPropertyAnimatorCompat viewpropertyanimatorcompat,
     View view,
     Runnable runnable) {
   viewpropertyanimatorcompat.mStartAction = runnable;
   postStartMessage(viewpropertyanimatorcompat, view);
 }
コード例 #8
0
  private void animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    if (deltaX != 0) {
      ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
      ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't
    // called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    mMoveAnimations.add(holder);
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation
        .setDuration(getMoveDuration())
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchMoveStarting(holder);
              }

              @Override
              public void onAnimationCancel(View view) {
                if (deltaX != 0) {
                  ViewCompat.setTranslationX(view, 0);
                }
                if (deltaY != 0) {
                  ViewCompat.setTranslationY(view, 0);
                }
              }

              @Override
              public void onAnimationEnd(View view) {
                animation.setListener(null);
                dispatchMoveFinished(holder);
                mMoveAnimations.remove(holder);
                dispatchFinishedWhenDone();
              }
            })
        .start();
  }
コード例 #9
0
 private void clearPressedItem()
 {
     mDrawsInPressedState = false;
     setPressed(false);
     drawableStateChanged();
     if (mClickAnimation != null)
     {
         mClickAnimation.cancel();
         mClickAnimation = null;
     }
 }
コード例 #10
0
  private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    int position = (int) view.getTag();
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    float endX, endY;
    if (position % 2 == 0) {
      endY = -100;
      endX = -width;
    } else {
      endY = 100;
      endX = width;
    }
    mRemoveAnimations.add(holder);
    animation.setInterpolator(new AnticipateOvershootInterpolator());
    animation
        .setDuration(getRemoveDuration())
        .alpha(0)
        .translationX(endX)
        .translationY(endY)
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchRemoveStarting(holder);
              }

              @Override
              public void onAnimationEnd(View view) {
                animation.setListener(null);
                // 重置为正常
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                dispatchRemoveFinished(holder);
                mRemoveAnimations.remove(holder);
                dispatchFinishedWhenDone();
              }
            })
        .start();
  }
コード例 #11
0
 @Override
 public void onAnimationEnd(View view) {
   if (mVpa.mOldLayerType >= 0) {
     ViewCompat.setLayerType(view, mVpa.mOldLayerType, null);
     mVpa.mOldLayerType = -1;
   }
   if (mVpa.mEndAction != null) {
     mVpa.mEndAction.run();
   }
   Object listenerTag = view.getTag(LISTENER_TAG_ID);
   ViewPropertyAnimatorListener listener = null;
   if (listenerTag instanceof ViewPropertyAnimatorListener) {
     listener = (ViewPropertyAnimatorListener) listenerTag;
   }
   if (listener != null) {
     listener.onAnimationEnd(view);
   }
 }
コード例 #12
0
 public void onAnimationEnd(View view1) {
   if (mVpa.mOldLayerType >= 0) {
     ViewCompat.setLayerType(view1, mVpa.mOldLayerType, null);
     mVpa.mOldLayerType = -1;
   }
   if (mVpa.mEndAction != null) {
     mVpa.mEndAction.run();
   }
   Object obj = view1.getTag(0x7e000000);
   if (obj instanceof ViewPropertyAnimatorListener) {
     obj = (ViewPropertyAnimatorListener) obj;
   } else {
     obj = null;
   }
   if (obj != null) {
     ((ViewPropertyAnimatorListener) (obj)).onAnimationEnd(view1);
   }
 }
コード例 #13
0
    void start() {
      final View containerView =
          ((SwipeableItemViewHolder) mViewHolder).getSwipeableContainerView();

      mInvSize =
          (1.0f
              / Math.max(1.0f, mHorizontal ? containerView.getWidth() : containerView.getHeight()));

      // setup animator
      mAnimator = ViewCompat.animate(containerView);
      mAnimator.setDuration(mDuration);
      mAnimator.translationX(mToX);
      mAnimator.translationY(mToY);
      if (mInterpolator != null) {
        mAnimator.setInterpolator(mInterpolator);
      }
      mAnimator.setListener(this);
      mAnimator.setUpdateListener(this);

      // start
      mActive.add(mViewHolder);
      mAnimator.start();
    }
コード例 #14
0
 @Override
 public void withLayer(ViewPropertyAnimatorCompat vpa, View view) {
   vpa.mOldLayerType = ViewCompat.getLayerType(view);
   ViewPropertyAnimatorCompatICS.setListener(view, new MyVpaListener(vpa));
 }
コード例 #15
0
 @Override
 public ViewPropertyAnimatorCompat removeAnimation(View view) {
   final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
   return animation.setDuration(getMoveDuration()).alpha(0).translationX(-view.getWidth());
 }
コード例 #16
0
  private void animateChangeImpl(final ChangeInfo changeInfo) {
    final ViewHolder holder = changeInfo.oldHolder;
    final View view = holder.itemView;
    final ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    mChangeAnimations.add(changeInfo.oldHolder);

    final ViewPropertyAnimatorCompat oldViewAnim =
        ViewCompat.animate(view).setDuration(getChangeDuration());
    oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
    oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
    oldViewAnim
        .alpha(0)
        .setListener(
            new VpaListenerAdapter() {
              @Override
              public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.oldHolder, true);
              }

              @Override
              public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                dispatchChangeFinished(changeInfo.oldHolder, true);
                mChangeAnimations.remove(changeInfo.oldHolder);
                dispatchFinishedWhenDone();
              }
            })
        .start();
    if (newView != null) {
      mChangeAnimations.add(changeInfo.newHolder);
      final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
      newViewAnimation
          .translationX(0)
          .translationY(0)
          .setDuration(getChangeDuration())
          .alpha(1)
          .setListener(
              new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                  dispatchChangeStarting(changeInfo.newHolder, false);
                }

                @Override
                public void onAnimationEnd(View view) {
                  newViewAnimation.setListener(null);
                  ViewCompat.setAlpha(newView, 1);
                  ViewCompat.setTranslationX(newView, 0);
                  ViewCompat.setTranslationY(newView, 0);
                  dispatchChangeFinished(changeInfo.newHolder, false);
                  mChangeAnimations.remove(changeInfo.newHolder);
                  dispatchFinishedWhenDone();
                }
              })
          .start();
    }
  }
コード例 #17
0
 public void withLayer(ViewPropertyAnimatorCompat viewpropertyanimatorcompat, View view) {
   viewpropertyanimatorcompat.mOldLayerType = ViewCompat.getLayerType(view);
   ViewPropertyAnimatorCompatICS.setListener(
       view, viewpropertyanimatorcompat.new MyVpaListener());
 }
コード例 #18
0
 @Override
 public void withStartAction(
     ViewPropertyAnimatorCompat vpa, View view, final Runnable runnable) {
   ViewPropertyAnimatorCompatICS.setListener(view, new MyVpaListener(vpa));
   vpa.mStartAction = runnable;
 }
コード例 #19
0
 public void withStartAction(
     ViewPropertyAnimatorCompat viewpropertyanimatorcompat, View view, Runnable runnable) {
   ViewPropertyAnimatorCompatICS.setListener(
       view, viewpropertyanimatorcompat.new MyVpaListener());
   viewpropertyanimatorcompat.mStartAction = runnable;
 }
コード例 #20
0
 @Override
 public void withStartAction(ViewPropertyAnimatorCompat vpa, View view, Runnable runnable) {
   vpa.mStartAction = runnable;
   postStartMessage(vpa, view);
 }