Last active
December 28, 2017 10:22
-
-
Save passiondroid/8c620f75ffd5f2ae11249569b69076f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 animateChange(@NonNull RecyclerView.ViewHolder oldHolder, | |
@NonNull RecyclerView.ViewHolder newHolder, | |
@NonNull ItemHolderInfo preInfo, | |
@NonNull ItemHolderInfo postInfo) { | |
if (preInfo instanceof CharacterItemHolderInfo) { | |
CharacterItemHolderInfo recipesItemHolderInfo = (CharacterItemHolderInfo) preInfo; | |
CharacterRVAdapter.CharacterViewHolder holder = (CharacterRVAdapter.CharacterViewHolder) newHolder; | |
if (CharacterRVAdapter.ACTION_LIKE_IMAGE_DOUBLE_CLICKED.equals(recipesItemHolderInfo.updateAction)) { | |
animatePhotoLike(holder); | |
} | |
} | |
return false; | |
} | |
private void animatePhotoLike(final CharacterRVAdapter.CharacterViewHolder holder) { | |
holder.likeIV.setVisibility(View.VISIBLE); | |
holder.likeIV.setScaleY(0.0f); | |
holder.likeIV.setScaleX(0.0f); | |
AnimatorSet animatorSet = new AnimatorSet(); | |
ObjectAnimator scaleLikeIcon = ObjectAnimator.ofPropertyValuesHolder | |
(holder.likeIV, PropertyValuesHolder.ofFloat("scaleX", 0.0f, 2.0f), | |
PropertyValuesHolder.ofFloat("scaleY", 0.0f, 2.0f), PropertyValuesHolder.ofFloat("alpha", 0.0f, 1.0f, 0.0f)); | |
scaleLikeIcon.setInterpolator(DECELERATE_INTERPOLATOR); | |
scaleLikeIcon.setDuration(1000); | |
ObjectAnimator scaleLikeBackground = ObjectAnimator.ofPropertyValuesHolder | |
(holder.characterCV, PropertyValuesHolder.ofFloat("scaleX", 1.0f, 0.95f, 1.0f), | |
PropertyValuesHolder.ofFloat("scaleY", 1.0f, 0.95f, 1.0f)); | |
scaleLikeBackground.setInterpolator(DECELERATE_INTERPOLATOR); | |
scaleLikeBackground.setDuration(600); | |
animatorSet.playTogether(scaleLikeIcon, scaleLikeBackground); | |
animatorSet.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment