change button animations
This commit is contained in:
parent
a7c707f62e
commit
06882d5bea
|
@ -48,7 +48,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
public static class Holder extends StatusDisplayItem.Holder<FooterStatusDisplayItem>{
|
public static class Holder extends StatusDisplayItem.Holder<FooterStatusDisplayItem>{
|
||||||
private final TextView reply, boost, favorite;
|
private final TextView reply, boost, favorite;
|
||||||
private final ImageView share;
|
private final ImageView share;
|
||||||
private static final AnimationSet scaleDown, scaleUp;
|
private static final Animation opacityOut, opacityIn;
|
||||||
|
|
||||||
private final View.AccessibilityDelegate buttonAccessibilityDelegate=new View.AccessibilityDelegate(){
|
private final View.AccessibilityDelegate buttonAccessibilityDelegate=new View.AccessibilityDelegate(){
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,24 +60,13 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
};
|
};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// 20dp to center in middle of icon, because: (icon width = 24dp) / 2 + (paddingStart = 8dp)
|
opacityOut = new AlphaAnimation(1, 0.5f);
|
||||||
Animation scaleDownAnim = new ScaleAnimation(1, 0.85f, 1, 0.85f, Animation.ABSOLUTE, V.dp(20), Animation.RELATIVE_TO_SELF, 0.5f);
|
opacityOut.setDuration(200);
|
||||||
Animation scaleUpAnim = new ScaleAnimation(0.85f, 1, 0.85f, 1, Animation.ABSOLUTE, V.dp(20), Animation.RELATIVE_TO_SELF, 0.5f);
|
opacityOut.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
Animation opacityOutAnim = new AlphaAnimation(1, 0.75f);
|
opacityOut.setFillAfter(true);
|
||||||
Animation opacityInAnim = new AlphaAnimation(0.75f, 1);
|
opacityIn = new AlphaAnimation(0.5f, 1);
|
||||||
|
opacityIn.setDuration(150);
|
||||||
scaleDown = new AnimationSet(true);
|
opacityIn.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||||
scaleDown.setDuration(350);
|
|
||||||
scaleDown.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
||||||
scaleDown.setFillAfter(true);
|
|
||||||
scaleDown.addAnimation(scaleDownAnim);
|
|
||||||
scaleDown.addAnimation(opacityOutAnim);
|
|
||||||
|
|
||||||
scaleUp = new AnimationSet(true);
|
|
||||||
scaleUp.setDuration(100);
|
|
||||||
scaleUp.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
||||||
scaleUp.addAnimation(scaleUpAnim);
|
|
||||||
scaleUp.addAnimation(opacityInAnim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder(Activity activity, ViewGroup parent){
|
public Holder(Activity activity, ViewGroup parent){
|
||||||
|
@ -131,7 +120,6 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onReplyClick(View v){
|
private void onReplyClick(View v){
|
||||||
v.startAnimation(scaleUp);
|
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", item.accountID);
|
args.putString("account", item.accountID);
|
||||||
args.putParcelable("replyTo", Parcels.wrap(item.status));
|
args.putParcelable("replyTo", Parcels.wrap(item.status));
|
||||||
|
@ -139,30 +127,37 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onButtonTouch(View v, MotionEvent event){
|
private boolean onButtonTouch(View v, MotionEvent event){
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) v.performClick();
|
int action = event.getAction();
|
||||||
else if (event.getAction() == MotionEvent.ACTION_DOWN) v.startAnimation(scaleDown);
|
// 20dp to center in middle of icon, because: (icon width = 24dp) / 2 + (paddingStart = 8dp)
|
||||||
else if (event.getAction() == MotionEvent.ACTION_CANCEL) v.startAnimation(scaleUp);
|
v.setPivotX(V.dp(20));
|
||||||
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
||||||
|
v.animate().scaleX(1).scaleY(1).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(100).start();
|
||||||
|
if (action == MotionEvent.ACTION_UP) v.performClick();
|
||||||
|
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||||
|
v.animate().scaleX(0.9f).scaleY(0.9f).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(50).start();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBoostClick(View v){
|
private void onBoostClick(View v){
|
||||||
|
v.startAnimation(opacityOut);
|
||||||
|
boost.setSelected(!item.status.reblogged);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, r->{
|
||||||
v.startAnimation(scaleUp);
|
v.startAnimation(opacityIn);
|
||||||
boost.setSelected(item.status.reblogged);
|
|
||||||
bindButton(boost, r.reblogsCount);
|
bindButton(boost, r.reblogsCount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFavoriteClick(View v){
|
private void onFavoriteClick(View v){
|
||||||
|
v.startAnimation(opacityOut);
|
||||||
|
favorite.setSelected(!item.status.favourited);
|
||||||
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
|
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
|
||||||
v.startAnimation(scaleUp);
|
v.startAnimation(opacityIn);
|
||||||
favorite.setSelected(r.favourited);
|
|
||||||
bindButton(favorite, r.favouritesCount);
|
bindButton(favorite, r.favouritesCount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShareClick(View v){
|
private void onShareClick(View v){
|
||||||
v.startAnimation(scaleUp);
|
|
||||||
Intent intent=new Intent(Intent.ACTION_SEND);
|
Intent intent=new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, item.status.url);
|
intent.putExtra(Intent.EXTRA_TEXT, item.status.url);
|
||||||
|
|
Loading…
Reference in New Issue