Fix currency not sorted when added back to ComboBox

When removing a previously selected fiat or crypto currency, it was
adding it back to the bottom of the combobox rather than alphabetically.
So make sure to sort when adding a currency to the list.
This commit is contained in:
Devin Bileck 2018-10-13 21:51:20 -07:00
parent 933b0b8277
commit 26d03afbb4
No known key found for this signature in database
GPG key ID: C86D829C2399D073

View file

@ -360,8 +360,10 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeFiatCurrency(item);
if (!allFiatCurrencies.contains(item))
if (!allFiatCurrencies.contains(item)) {
allFiatCurrencies.add(item);
allFiatCurrencies.sort(TradeCurrency::compareTo);
}
}
});
setGraphic(pane);
@ -410,8 +412,10 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeCryptoCurrency(item);
if (!allCryptoCurrencies.contains(item))
if (!allCryptoCurrencies.contains(item)) {
allCryptoCurrencies.add(item);
allCryptoCurrencies.sort(TradeCurrency::compareTo);
}
}
});
setGraphic(pane);