Fix issue with static initializer

This commit is contained in:
Manfred Karrer 2017-04-07 20:08:53 -05:00
parent a448444bf1
commit 7ca02c0be6

View file

@ -40,8 +40,6 @@ import lombok.extern.slf4j.Slf4j;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.MonetaryFormat; import org.bitcoinj.utils.MonetaryFormat;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
@ -54,6 +52,23 @@ public final class PreferencesImpl implements Preferences {
///////////////// START of STATIC //////////////////////////////////////////////////////////////////////// ///////////////// START of STATIC ////////////////////////////////////////////////////////////////////////
static {
Locale locale = Locale.getDefault();
PreferencesImpl.defaultLocale = locale;
Res.applyLocaleToResourceBundle(getDefaultLocale());
CountryUtil.setDefaultLocale(locale);
CurrencyUtil.setDefaultLocale(locale);
LanguageUtil.setDefaultLocale(locale);
FiatCurrency.setDefaultLocale(locale);
FiatCurrency currencyByCountryCode = CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode(locale), locale);
PreferencesImpl.defaultTradeCurrency = currencyByCountryCode;
CurrencyUtil.setDefaultTradeCurrency(currencyByCountryCode);
}
// That object is saved to disc. We need to take care of changes to not break deserialization. // That object is saved to disc. We need to take care of changes to not break deserialization.
private static final long serialVersionUID = Version.LOCAL_DB_VERSION; private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
@ -86,7 +101,7 @@ public final class PreferencesImpl implements Preferences {
)); ));
@Getter @Getter
private static Locale defaultLocale = Locale.getDefault(); private static Locale defaultLocale/* = Locale.getDefault()*/;
@Getter @Getter
private static TradeCurrency defaultTradeCurrency; private static TradeCurrency defaultTradeCurrency;
@ -98,6 +113,7 @@ public final class PreferencesImpl implements Preferences {
public static List<String> getBtcDenominations() { public static List<String> getBtcDenominations() {
return BTC_DENOMINATIONS; return BTC_DENOMINATIONS;
} }
public static boolean useAnimations() { public static boolean useAnimations() {
return staticUseAnimations; return staticUseAnimations;
} }
@ -214,6 +230,7 @@ public final class PreferencesImpl implements Preferences {
this.bisqEnvironment = bisqEnvironment; this.bisqEnvironment = bisqEnvironment;
// setup // setup
/*
Res.applyLocaleToResourceBundle(defaultLocale); Res.applyLocaleToResourceBundle(defaultLocale);
CountryUtil.setDefaultLocale(defaultLocale); CountryUtil.setDefaultLocale(defaultLocale);
CurrencyUtil.setDefaultLocale(defaultLocale); CurrencyUtil.setDefaultLocale(defaultLocale);
@ -223,6 +240,7 @@ public final class PreferencesImpl implements Preferences {
FiatCurrency currencyByCountryCode = CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode(defaultLocale), defaultLocale); FiatCurrency currencyByCountryCode = CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode(defaultLocale), defaultLocale);
defaultTradeCurrency = currencyByCountryCode; defaultTradeCurrency = currencyByCountryCode;
CurrencyUtil.setDefaultTradeCurrency(currencyByCountryCode); CurrencyUtil.setDefaultTradeCurrency(currencyByCountryCode);
*/
// end setup // end setup
directoryChooserPath = Utilities.getSystemHomeDirectory(); directoryChooserPath = Utilities.getSystemHomeDirectory();