Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RecyclerViewAnimations source files
@Override
public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) {
return true;
}
//ColorsAdapter.java
public void changeItemAtPosition(int position) {
colors.set(position, ColorsHelper.getRandomColor());
notifyItemChanged(position);
}
private class ColorTextInfo extends ItemHolderInfo {
int color;
String text;
//...
}
//MainActivity.java
LinearLayoutManager layoutManager = new LinearLayoutManager(this) {
@Override
public boolean supportsPredictiveItemAnimations() {
return cbPredictive.isChecked();
}
};
rvColors.setLayoutManager(layoutManager);
@Override
public void onBindViewHolder(ColorViewHolder holder, int position) {
int color = colors.get(position);
holder.itemView.setBackgroundColor(color);
holder.tvColor.setText("#" + Integer.toHexString(color));
}
overallAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
dispatchAnimationFinished(newHolder);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.