Skip to content

Instantly share code, notes, and snippets.

@jedsada-gh
Created February 6, 2017 07:06
Show Gist options
  • Save jedsada-gh/98a9a49f215ed2f02981d2f19fb23c0b to your computer and use it in GitHub Desktop.
Save jedsada-gh/98a9a49f215ed2f02981d2f19fb23c0b to your computer and use it in GitHub Desktop.
@Override
public void onViewAttachedToWindow(VH holder) {
super.onViewAttachedToWindow(holder);
int position;
if (holder.getItemViewType() == TYPE_ITEM) {
position = holder.getAdapterPosition();
if (position > lastPosition) {
lastPosition = position;
holder.itemView.startAnimation(getAnim(holder.itemView.getContext()));
}
}
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
@Override
public void onViewDetachedFromWindow(VH holder) {
super.onViewDetachedFromWindow(holder);
if (holder.getItemViewType() == TYPE_ITEM)
holder.itemView.clearAnimation();
}
private Animation getAnim(@NotNull Context context) {
return AnimationUtils.loadAnimation(context, R.anim.up_from_bottom);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment