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

View file

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

View file

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