public void setupViewOptions() { setTextSize(adapter.getTextSize()); mediaPreview.setStyle(adapter.getMediaPreviewStyle()); // profileImageView.setStyle(adapter.getProfileImageStyle()); final boolean nameFirst = adapter.isNameFirst(); nameView.setNameFirst(nameFirst); quotedNameView.setNameFirst(nameFirst); final int favIcon, favStyle, favColor; final Context context = adapter.getContext(); if (adapter.shouldUseStarsForLikes()) { favIcon = R.drawable.ic_action_star; favStyle = LikeAnimationDrawable.Style.FAVORITE; favColor = ContextCompat.getColor(context, R.color.highlight_favorite); } else { favIcon = R.drawable.ic_action_heart; favStyle = LikeAnimationDrawable.Style.LIKE; favColor = ContextCompat.getColor(context, R.color.highlight_like); } final Drawable icon = ContextCompat.getDrawable(context, favIcon); final LikeAnimationDrawable drawable = new LikeAnimationDrawable( icon, favoriteCountView.getTextColors().getDefaultColor(), favColor, favStyle); drawable.mutate(); favoriteIconView.setImageDrawable(drawable); timeView.setShowAbsoluteTime(adapter.isShowAbsoluteTime()); favoriteIconView.setActivatedColor(favColor); }
@Override public void playLikeAnimation(@NonNull LikeAnimationDrawable.OnLikedListener listener) { boolean handled = false; final Drawable drawable = favoriteIconView.getDrawable(); if (drawable instanceof LikeAnimationDrawable) { ((LikeAnimationDrawable) drawable).setOnLikedListener(listener); ((LikeAnimationDrawable) drawable).start(); handled = true; } if (!handled) { listener.onLiked(); } }