Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements #1727

Merged
merged 2 commits into from Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -74,6 +74,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

class TradesChartsViewModel extends ActivatableViewModel {

private static final int TAB_INDEX = 2;
Expand Down Expand Up @@ -129,7 +131,10 @@ public TradesChartsViewModel(TradeStatisticsManager tradeStatisticsManager, Pref
fillTradeCurrencies();
};

Optional<TradeCurrency> tradeCurrencyOptional = CurrencyUtil.getTradeCurrency(preferences.getTradeChartsScreenCurrencyCode());
String tradeChartsScreenCurrencyCode = preferences.getTradeChartsScreenCurrencyCode();
showAllTradeCurrenciesProperty.set(isShowAllEntry(tradeChartsScreenCurrencyCode));

Optional<TradeCurrency> tradeCurrencyOptional = CurrencyUtil.getTradeCurrency(tradeChartsScreenCurrencyCode);
if (tradeCurrencyOptional.isPresent())
selectedTradeCurrencyProperty.set(tradeCurrencyOptional.get());
else
Expand Down Expand Up @@ -186,8 +191,8 @@ void onSetTradeCurrency(TradeCurrency tradeCurrency) {
showAllTradeCurrenciesProperty.set(showAllEntry);
if (!showAllEntry) {
selectedTradeCurrencyProperty.set(tradeCurrency);
preferences.setTradeChartsScreenCurrencyCode(code);
}
preferences.setTradeChartsScreenCurrencyCode(code);

updateChartData();

Expand Down Expand Up @@ -376,11 +381,11 @@ long getTimeFromTickIndex(long index) {
return getTimeFromTick(index);
}

private boolean isShowAllEntry(String id) {
return id.equals(GUIUtil.SHOW_ALL_FLAG);
private boolean isShowAllEntry(@Nullable String id) {
return id != null && id.equals(GUIUtil.SHOW_ALL_FLAG);
}

private boolean isEditEntry(String id) {
return id.equals(GUIUtil.EDIT_FLAG);
private boolean isEditEntry(@Nullable String id) {
return id != null && id.equals(GUIUtil.EDIT_FLAG);
}
}