Last active
February 3, 2019 20:56
-
-
Save frogermcs/cb79a9111fbbdabaa4d9 to your computer and use it in GitHub Desktop.
InstaMaterial source files (comments transitions)
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 void animatePhotoLike(final CellFeedViewHolder holder) { | |
if (!likeAnimations.containsKey(holder)) { | |
holder.vBgLike.setVisibility(View.VISIBLE); | |
holder.ivLike.setVisibility(View.VISIBLE); | |
holder.vBgLike.setScaleY(0.1f); | |
holder.vBgLike.setScaleX(0.1f); | |
holder.vBgLike.setAlpha(1f); | |
holder.ivLike.setScaleY(0.1f); | |
holder.ivLike.setScaleX(0.1f); | |
AnimatorSet animatorSet = new AnimatorSet(); | |
likeAnimations.put(holder, animatorSet); | |
ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleY", 0.1f, 1f); | |
bgScaleYAnim.setDuration(200); | |
bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); | |
ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleX", 0.1f, 1f); | |
bgScaleXAnim.setDuration(200); | |
bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); | |
ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(holder.vBgLike, "alpha", 1f, 0f); | |
bgAlphaAnim.setDuration(200); | |
bgAlphaAnim.setStartDelay(150); | |
bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR); | |
ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 0.1f, 1f); | |
imgScaleUpYAnim.setDuration(300); | |
imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); | |
ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 0.1f, 1f); | |
imgScaleUpXAnim.setDuration(300); | |
imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); | |
ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 1f, 0f); | |
imgScaleDownYAnim.setDuration(300); | |
imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); | |
ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 1f, 0f); | |
imgScaleDownXAnim.setDuration(300); | |
imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR); | |
animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim); | |
animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim); | |
animatorSet.addListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
resetLikeAnimationState(holder); | |
} | |
}); | |
animatorSet.start(); | |
} | |
} |
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 void updateLikesCounter(CellFeedViewHolder holder, boolean animated) { | |
int currentLikesCount = likesCount.get(holder.getPosition()) + 1; | |
String likesCountText = context.getResources().getQuantityString( | |
R.plurals.likes_count, currentLikesCount, currentLikesCount | |
); | |
if (animated) { | |
holder.tsLikesCounter.setText(likesCountText); | |
} else { | |
holder.tsLikesCounter.setCurrentText(likesCountText); | |
} | |
likesCount.put(holder.getPosition(), currentLikesCount); | |
} |
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
<!--...--> | |
<LinearLayout | |
android:layout_width="0dp" | |
android:layout_height="match_parent" | |
android:layout_weight="1" | |
android:gravity="center_vertical|right"> | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:src="@drawable/ic_heart_small_blue" /> | |
<TextSwitcher | |
android:id="@+id/tsLikesCounter" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginLeft="8dp" | |
android:layout_marginRight="8dp" | |
android:inAnimation="@anim/slide_in_likes_counter" | |
android:outAnimation="@anim/slide_out_likes_counter"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="123 likes" | |
android:textColor="@color/text_like_counter" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textColor="@color/text_like_counter" /> | |
</TextSwitcher> | |
</LinearLayout> | |
<!--...--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment