Skip to content

Commit

Permalink
fix: make favorite button spin again
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGGamerM committed Oct 13, 2023
1 parent 9964236 commit 1e7e481
Showing 1 changed file with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static class Holder extends StatusDisplayItem.Holder<FooterStatusDisplayI
private final TextView replies, boosts, favorites;
private final View reply, boost, favorite, share, bookmark;
private final ImageView favIcon;
private static AnimationSet animSet;
private static Animation spin;


private View touchingView = null;
Expand All @@ -87,6 +87,13 @@ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo i
}
};

static {
spin = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
spin.setDuration(400);
}

public Holder(Activity activity, ViewGroup parent){
super(activity, R.layout.display_item_footer, parent);

Expand Down Expand Up @@ -123,27 +130,6 @@ public Holder(Activity activity, ViewGroup parent){
share.setAccessibilityDelegate(buttonAccessibilityDelegate);
}

private static final float ALPHA_PRESSED=0.55f;

static {
AlphaAnimation opacityOut = new AlphaAnimation(1, ALPHA_PRESSED);
opacityOut.setDuration(300);
opacityOut.setInterpolator(CubicBezierInterpolator.DEFAULT);
opacityOut.setFillAfter(true);
AlphaAnimation opacityIn = new AlphaAnimation(ALPHA_PRESSED, 1);
opacityIn.setDuration(400);
opacityIn.setInterpolator(CubicBezierInterpolator.DEFAULT);
Animation spin = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);

animSet = new AnimationSet(true);
animSet.setInterpolator(CubicBezierInterpolator.DEFAULT);
animSet.addAnimation(spin);
animSet.addAnimation(opacityIn);
animSet.setDuration(400);
}

@Override
public void onBind(FooterStatusDisplayItem item){
bindText(replies, item.status.repliesCount);
Expand Down Expand Up @@ -386,10 +372,9 @@ private void onFavoriteClick(View v){
vibrateForAction(favorite, !status.favourited);
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(status, !status.favourited, r->{
if (status.favourited && !GlobalUserPreferences.reduceMotion) {
v.startAnimation(animSet);
} else {
UiUtils.opacityIn(v);
v.startAnimation(spin);
}
UiUtils.opacityIn(v);
bindText(favorites, r.favouritesCount);
});
}
Expand All @@ -400,10 +385,9 @@ private void onFavoriteClick(View v){
vibrateForAction(favorite, !item.status.favourited);
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
if (item.status.favourited && !GlobalUserPreferences.reduceMotion) {
v.startAnimation(animSet);
} else {
UiUtils.opacityIn(v);
v.startAnimation(spin);
}
UiUtils.opacityIn(v);
bindText(favorites, r.favouritesCount);
});
}
Expand Down

0 comments on commit 1e7e481

Please sign in to comment.