public static void closeViewHolder( final ExpandableIdeaAdapter.ViewHolder holder, final View bottomView, final View topView, final boolean animate) { if (animate) { bottomView.setVisibility(View.GONE); topView.setVisibility(View.GONE); if (holder.animatorSet != null) holder.animatorSet.cancel(); holder.animatorSet = new AnimatorSet(); Animator bottomAnimator = ExpandableIdeaAnimator.ofItemViewHeight(holder, false); Animator topAnimator = ExpandableIdeaAnimator.ofViewHeight(topView, false); Animator cardElevationAnimator = LayoutAnimator.ofCardViewElevation((CardView) holder.itemView, 12, 0); bottomView.setVisibility(View.VISIBLE); topView.setVisibility(View.VISIBLE); holder.animatorSet.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { bottomView.setVisibility(View.GONE); topView.setVisibility(View.GONE); } }); holder.animatorSet.play(bottomAnimator).with(topAnimator).with(cardElevationAnimator); holder.animatorSet.start(); } else { bottomView.setVisibility(View.GONE); topView.setVisibility(View.GONE); } }
public static void openViewHolder( final ExpandableIdeaAdapter.ViewHolder holder, final View bottomView, final View topView, final boolean animate) { if (animate) { if (holder.animatorSet != null) holder.animatorSet.cancel(); holder.animatorSet = new AnimatorSet(); bottomView.setVisibility(View.VISIBLE); topView.setVisibility(View.VISIBLE); Animator bottomAnimator = ExpandableIdeaAnimator.ofItemViewHeight(holder, true); Animator topAnimator = ExpandableIdeaAnimator.ofViewHeight(topView, true); Animator cardElevationAnimator = LayoutAnimator.ofCardViewElevation((CardView) holder.itemView, 0, 12); holder.animatorSet.play(bottomAnimator).with(topAnimator).with(cardElevationAnimator); holder.animatorSet.start(); } else { bottomView.setVisibility(View.VISIBLE); topView.setVisibility(View.VISIBLE); } }