Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Hierarchical Timing specification for all animators in accordance with Google Material Design motion guidelines #66

Merged
merged 3 commits into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,22 @@ private void doAnimateAdd(final RecyclerView.ViewHolder holder) {
return true;
}

protected long getRemoveDelay(final RecyclerView.ViewHolder holder) {
return Math.abs(holder.getOldPosition() * getRemoveDuration() / 4);
}

@Override public boolean animateAdd(final ViewHolder holder) {
endAnimation(holder);
preAnimateAdd(holder);
mPendingAdditions.add(holder);
return true;
}


protected long getAddDelay(final RecyclerView.ViewHolder holder) {
return Math.abs(holder.getAdapterPosition() * getAddDuration() / 4);
}

@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
final View view = holder.itemView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FadeInAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -48,6 +49,7 @@ public FadeInAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public FadeInDownAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -51,6 +52,7 @@ public FadeInDownAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public FadeInLeftAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -51,6 +52,7 @@ public FadeInLeftAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public FadeInRightAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -51,6 +52,7 @@ public FadeInRightAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public FadeInUpAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -51,6 +52,7 @@ public FadeInUpAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FlipInBottomXAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -48,6 +49,7 @@ public FlipInBottomXAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FlipInLeftYAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -48,6 +49,7 @@ public FlipInLeftYAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FlipInRightYAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -48,6 +49,7 @@ public FlipInRightYAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FlipInTopXAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -48,6 +49,7 @@ public FlipInTopXAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public LandingAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -54,6 +55,7 @@ public LandingAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public OvershootInLeftAnimator(float mTension) {
.translationX(-holder.itemView.getRootView().getWidth())
.setDuration(getRemoveDuration())
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -50,6 +51,7 @@ public OvershootInLeftAnimator(float mTension) {
.setDuration(getAddDuration())
.setListener(new DefaultAddVpaListener(holder))
.setInterpolator(new OvershootInterpolator(mTension))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public OvershootInRightAnimator(float mTension) {
.translationX(holder.itemView.getRootView().getWidth())
.setDuration(getRemoveDuration())
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -50,6 +51,7 @@ public OvershootInRightAnimator(float mTension) {
.setDuration(getAddDuration())
.setInterpolator(new OvershootInterpolator(mTension))
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ public ScaleInAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}


@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
ViewCompat.setScaleX(holder.itemView, 0);
ViewCompat.setScaleY(holder.itemView, 0);
Expand All @@ -51,6 +53,7 @@ public ScaleInAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ScaleInBottomAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -60,6 +61,7 @@ public ScaleInBottomAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public ScaleInLeftAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -56,6 +57,7 @@ public ScaleInLeftAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public ScaleInRightAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -56,6 +57,7 @@ public ScaleInRightAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ScaleInTopAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -60,6 +61,7 @@ public ScaleInTopAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public SlideInDownAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -52,6 +53,7 @@ public SlideInDownAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public SlideInLeftAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -49,6 +50,7 @@ public SlideInLeftAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public SlideInRightAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -49,6 +50,7 @@ public SlideInRightAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public SlideInUpAnimator(Interpolator interpolator) {
.setDuration(getRemoveDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultRemoveVpaListener(holder))
.setStartDelay(getRemoveDelay(holder))
.start();
}

Expand All @@ -52,6 +53,7 @@ public SlideInUpAnimator(Interpolator interpolator) {
.setDuration(getAddDuration())
.setInterpolator(mInterpolator)
.setListener(new DefaultAddVpaListener(holder))
.setStartDelay(getAddDelay(holder))
.start();
}
}