我想从 InstaMaterial(Miroslaw Stanek 的)了解这个变量的用途

I want to know about this variable's purpose from InstaMaterial(of Miroslaw Stanek)

请检查此页面 -> http://frogermcs.github.io/InstaMaterial-concept-part-5-like_action_effects/

我只是在学习 InstaMaterial 的源代码。我几乎看懂了大部分代码。但是我不明白 FeedAdapter 中的 "likeAnimations" 变量代表什么。

我知道这是一个Hash Map。我认为这是为了防止重复调用。虽然不是...

谁能解释一下这个变量的用途?

FeedAdapter 的完整源代码在这里 -> https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/java/io/github/froger/instamaterial/ui/adapter/FeedAdapter.java

如有任何进展,我将不胜感激。

在会员区。

private final Map<RecyclerView.ViewHolder, AnimatorSet> likeAnimations = new HashMap<>();

在"animatePhotoLike"方法处。

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();
    // It puts 'holder' and 'AnimatorSet' into this HashMap before starting animations.
    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) {
            // It removes the item from the HashMap which contains this holder as key value when all animations are finisehd.
            resetLikeAnimationState(holder);
        }
    });
    animatorSet.start();
}}

在"resetLikeAnimationState"方法处。

private void resetLikeAnimationState(CellFeedViewHolder holder) {
    likeAnimations.remove(holder);
    holder.vBgLike.setVisibility(View.GONE);
    holder.ivLike.setVisibility(View.GONE);
}

谢谢,米罗斯瓦夫!

(正如miroslaw在我的问题下评论的那样)