Last active
January 10, 2016 18:44
-
-
Save frogermcs/ce58f22bc46fca76ed2e to your computer and use it in GitHub Desktop.
RecyclerViewAnimations source files
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
@Override | |
public boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder) { | |
return true; | |
} |
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
//ColorsAdapter.java | |
public void changeItemAtPosition(int position) { | |
colors.set(position, ColorsHelper.getRandomColor()); | |
notifyItemChanged(position); | |
} |
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
private class ColorTextInfo extends ItemHolderInfo { | |
int color; | |
String text; | |
//... | |
} |
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
//MainActivity.java | |
LinearLayoutManager layoutManager = new LinearLayoutManager(this) { | |
@Override | |
public boolean supportsPredictiveItemAnimations() { | |
return cbPredictive.isChecked(); | |
} | |
}; | |
rvColors.setLayoutManager(layoutManager); |
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
@Override | |
public void onBindViewHolder(ColorViewHolder holder, int position) { | |
int color = colors.get(position); | |
holder.itemView.setBackgroundColor(color); | |
holder.tvColor.setText("#" + Integer.toHexString(color)); | |
} |
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
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