This repository has been archived by the owner on Jan 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update AboutLibraries * add rebound library from Android to make a smooth animation * use IconicsDrawable instead of real drawable. * add SwipeRefreshLayout * some other changes
- Loading branch information
Showing
8 changed files
with
267 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
app/src/main/java/com/mikepenz/lollipopshowcase/itemanimator/CustomItemAnimator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.mikepenz.lollipopshowcase.itemanimator; | ||
|
||
import android.animation.Animator; | ||
import android.animation.AnimatorSet; | ||
import android.animation.ObjectAnimator; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.view.animation.AccelerateDecelerateInterpolator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class CustomItemAnimator extends RecyclerView.ItemAnimator { | ||
|
||
List<RecyclerView.ViewHolder> mViewHolders = new ArrayList<RecyclerView.ViewHolder>(); | ||
|
||
@Override | ||
public void runPendingAnimations() { | ||
if (!mViewHolders.isEmpty()) { | ||
int animationDuration = 300; | ||
AnimatorSet animator; | ||
View target; | ||
for (final RecyclerView.ViewHolder viewHolder : mViewHolders) { | ||
target = viewHolder.itemView; | ||
target.setPivotX(target.getMeasuredWidth() / 2); | ||
target.setPivotY(target.getMeasuredHeight() / 2); | ||
|
||
animator = new AnimatorSet(); | ||
|
||
animator.playTogether( | ||
ObjectAnimator.ofFloat(target, "translationX", -target.getMeasuredWidth(), 0.0f), | ||
ObjectAnimator.ofFloat(target, "alpha", target.getAlpha(), 1.0f) | ||
); | ||
|
||
animator.setTarget(target); | ||
animator.setDuration(animationDuration); | ||
animator.setInterpolator(new AccelerateDecelerateInterpolator()); | ||
animator.setStartDelay((animationDuration * viewHolder.getPosition()) / 10); | ||
animator.addListener(new Animator.AnimatorListener() { | ||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
mViewHolders.remove(viewHolder); | ||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator animation) { | ||
|
||
} | ||
}); | ||
animator.start(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean animateRemove(RecyclerView.ViewHolder viewHolder) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean animateAdd(RecyclerView.ViewHolder viewHolder) { | ||
viewHolder.itemView.setAlpha(0.0f); | ||
return mViewHolders.add(viewHolder); | ||
} | ||
|
||
@Override | ||
public boolean animateMove(RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void endAnimation(RecyclerView.ViewHolder viewHolder) { | ||
} | ||
|
||
@Override | ||
public void endAnimations() { | ||
} | ||
|
||
@Override | ||
public boolean isRunning() { | ||
return !mViewHolders.isEmpty(); | ||
} | ||
|
||
} |
Oops, something went wrong.