Add missing support to deactivate animations

This commit is contained in:
Manfred Karrer 2016-03-11 12:57:40 +01:00
parent 415530c8ef
commit 4fc3b00fa4
3 changed files with 12 additions and 7 deletions

View File

@ -83,6 +83,8 @@ public final class Preferences implements Persistable {
return defaultTradeCurrency;
}
private static boolean _useAnimations = true;
transient private final Storage<Preferences> storage;
transient private final BitsquareEnvironment bitsquareEnvironment;
@ -184,6 +186,7 @@ public final class Preferences implements Persistable {
});
useAnimationsProperty.addListener((ov) -> {
useAnimations = useAnimationsProperty.get();
_useAnimations = useAnimations;
storage.queueUpForSave(2000);
});
fiatCurrenciesAsObservable.addListener((Observable ov) -> {
@ -351,6 +354,10 @@ public final class Preferences implements Persistable {
return useAnimationsProperty.get();
}
public static boolean useAnimations() {
return _useAnimations;
}
public StringProperty btcDenominationProperty() {
return btcDenominationProperty;
}

View File

@ -740,11 +740,8 @@ public abstract class Overlay<T extends Overlay> {
truncatedMessage = message;
}
private int getDuration(int duration) {
if (preferences != null)
return preferences.getUseAnimations() ? duration : 1;
else
return duration;
protected int getDuration(int duration) {
return Preferences.useAnimations() ? duration : 1;
}
@Override

View File

@ -94,7 +94,7 @@ public class Notification extends Overlay<Notification> {
}
if (NotificationCenter.useAnimations) {
double duration = 400;
double duration = getDuration(400);
Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
gridPane.setRotationAxis(Rotate.X_AXIS);
@ -127,7 +127,7 @@ public class Notification extends Overlay<Notification> {
protected void animateDisplay() {
if (NotificationCenter.useAnimations) {
double startX = 320;
double duration = 600;
double duration = getDuration(600);
Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
Timeline timeline = new Timeline();
@ -154,6 +154,7 @@ public class Notification extends Overlay<Notification> {
}
}
@Override
protected void createGridPane() {
super.createGridPane();