mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Better button animation
This commit is contained in:
@@ -82,8 +82,8 @@ public class ListNodesWithAddButtonView extends RelativeLayout {
|
|||||||
animationDuration = 300L;
|
animationDuration = 300L;
|
||||||
|
|
||||||
viewButtonMenuAnimation = new AddButtonAnimation(addButton);
|
viewButtonMenuAnimation = new AddButtonAnimation(addButton);
|
||||||
viewMenuAnimationAddEntry = new ViewMenuAnimation(addEntry);
|
viewMenuAnimationAddEntry = new ViewMenuAnimation(addEntry, 0L, 150L);
|
||||||
viewMenuAnimationAddGroup = new ViewMenuAnimation(addGroup);
|
viewMenuAnimationAddGroup = new ViewMenuAnimation(addGroup, 150L, 0L);
|
||||||
|
|
||||||
allowAction = true;
|
allowAction = true;
|
||||||
state = State.CLOSE;
|
state = State.CLOSE;
|
||||||
@@ -248,12 +248,20 @@ public class ListNodesWithAddButtonView extends RelativeLayout {
|
|||||||
private Interpolator interpolator;
|
private Interpolator interpolator;
|
||||||
private float translation;
|
private float translation;
|
||||||
private boolean wasInvisible;
|
private boolean wasInvisible;
|
||||||
|
private long delayIn;
|
||||||
|
private long delayOut;
|
||||||
|
|
||||||
ViewMenuAnimation(View view) {
|
ViewMenuAnimation(View view, long delayIn, long delayOut) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.interpolator = new FastOutSlowInInterpolator();
|
this.interpolator = new FastOutSlowInInterpolator();
|
||||||
this.wasInvisible = true;
|
this.wasInvisible = true;
|
||||||
this.translation = 0;
|
this.translation = 0;
|
||||||
|
this.delayIn = delayIn;
|
||||||
|
this.delayOut = delayOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewMenuAnimation(View view) {
|
||||||
|
this(view, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -273,15 +281,17 @@ public class ListNodesWithAddButtonView extends RelativeLayout {
|
|||||||
|
|
||||||
void startAnimation() {
|
void startAnimation() {
|
||||||
if(view.getVisibility() == VISIBLE) {
|
if(view.getVisibility() == VISIBLE) {
|
||||||
|
// In
|
||||||
wasInvisible = false;
|
wasInvisible = false;
|
||||||
ViewCompat.animate(view)
|
ViewCompat.animate(view)
|
||||||
.translationY(-translation)
|
.translationY(-translation)
|
||||||
.translationX(view.getWidth()/3)
|
.translationX(view.getWidth()/3)
|
||||||
.alpha(0.0F)
|
.alpha(0.0F)
|
||||||
.scaleX(0.33F)
|
.scaleX(0.33F)
|
||||||
.setDuration(animationDuration)
|
.setDuration(animationDuration-delayIn)
|
||||||
.setInterpolator(interpolator)
|
.setInterpolator(interpolator)
|
||||||
.setListener(this)
|
.setListener(this)
|
||||||
|
.setStartDelay(delayIn)
|
||||||
.start();
|
.start();
|
||||||
} else {
|
} else {
|
||||||
// The first time
|
// The first time
|
||||||
@@ -293,6 +303,7 @@ public class ListNodesWithAddButtonView extends RelativeLayout {
|
|||||||
view.setScaleX(0.33F);
|
view.setScaleX(0.33F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Out
|
||||||
view.setVisibility(VISIBLE);
|
view.setVisibility(VISIBLE);
|
||||||
wasInvisible = true;
|
wasInvisible = true;
|
||||||
ViewCompat.animate(view)
|
ViewCompat.animate(view)
|
||||||
@@ -300,9 +311,10 @@ public class ListNodesWithAddButtonView extends RelativeLayout {
|
|||||||
.translationX(1)
|
.translationX(1)
|
||||||
.alpha(1.0F)
|
.alpha(1.0F)
|
||||||
.scaleX(1)
|
.scaleX(1)
|
||||||
.setDuration(animationDuration)
|
.setDuration(animationDuration-delayOut)
|
||||||
.setInterpolator(interpolator)
|
.setInterpolator(interpolator)
|
||||||
.setListener(this)
|
.setListener(this)
|
||||||
|
.setStartDelay(delayOut)
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user