Skip to content

Commit

Permalink
Make stateless BSFormatter functions static and remove dead code
Browse files Browse the repository at this point in the history
Making these functions static is a preparation for extraction.
  • Loading branch information
Justin Carter committed Sep 11, 2019
1 parent 322fe23 commit 57d9bad
Show file tree
Hide file tree
Showing 53 changed files with 243 additions and 261 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/WalletAppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void init(@Nullable Consumer<String> chainFileLockedExceptionHandler,
result = Res.get("mainView.footer.btcInfo",
peers,
Res.get("mainView.footer.btcInfo.synchronizingWith"),
getBtcNetworkAsString() + ": " + formatter.formatToPercentWithSymbol(percentage));
getBtcNetworkAsString() + ": " + BSFormatter.formatToPercentWithSymbol(percentage));
} else {
result = Res.get("mainView.footer.btcInfo",
peers,
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/bisq/core/dao/presentation/DaoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static String getNextPhaseDuration(int height, DaoPhase.Phase phase, DaoF
long now = new Date().getTime();
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd MMM", Locale.getDefault());
SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm", Locale.getDefault());
String startDateTime = formatter.formatDateTime(new Date(now + (start - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String endDateTime = formatter.formatDateTime(new Date(now + (end - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String startDateTime = BSFormatter.formatDateTime(new Date(now + (start - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String endDateTime = BSFormatter.formatDateTime(new Date(now + (end - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);

return Res.get("dao.cycle.phaseDurationWithoutBlocks", start, end, startDateTime, endDateTime);
}
Expand All @@ -53,9 +53,9 @@ public static String getPhaseDuration(int height, DaoPhase.Phase phase, DaoFacad
long now = new Date().getTime();
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd MMM", Locale.getDefault());
SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm", Locale.getDefault());
String startDateTime = formatter.formatDateTime(new Date(now + (start - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String endDateTime = formatter.formatDateTime(new Date(now + (end - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String durationTime = formatter.formatDurationAsWords(duration * 10 * 60 * 1000, false, false);
String startDateTime = BSFormatter.formatDateTime(new Date(now + (start - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String endDateTime = BSFormatter.formatDateTime(new Date(now + (end - height) * 10 * 60 * 1000L), dateFormatter, timeFormatter);
String durationTime = BSFormatter.formatDurationAsWords(duration * 10 * 60 * 1000, false, false);
return Res.get("dao.cycle.phaseDuration", duration, durationTime, start, end, startDateTime, endDateTime);
}
}
3 changes: 2 additions & 1 deletion core/src/main/java/bisq/core/dao/state/DaoStateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import bisq.core.dao.state.model.governance.Issuance;
import bisq.core.dao.state.model.governance.IssuanceType;
import bisq.core.dao.state.model.governance.ParamChange;
import bisq.core.util.BSFormatter;
import bisq.core.util.BsqFormatter;

import org.bitcoinj.core.Coin;
Expand Down Expand Up @@ -923,7 +924,7 @@ public Coin getParamValueAsCoin(Param param, String paramValue) {
}

public double getParamValueAsPercentDouble(String paramValue) {
return bsqFormatter.parsePercentStringToDouble(paramValue);
return BSFormatter.parsePercentStringToDouble(paramValue);
}

public int getParamValueAsBlock(String paramValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ else if (!isFiatCurrency && !isSellOffer)
ratio = Math.abs(ratio);
String msg = Res.get("account.notifications.marketAlert.message.msg",
direction,
formatter.getCurrencyPair(currencyCode),
BSFormatter.getCurrencyPair(currencyCode),
formatter.formatPrice(offerPrice),
formatter.formatToPercentWithSymbol(ratio / 10000d),
BSFormatter.formatToPercentWithSymbol(ratio / 10000d),
marketDir,
Res.get(offer.getPaymentMethod().getId()),
shortOfferId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private void update() {
if (priceAsLong > filter.getHigh() || priceAsLong < filter.getLow()) {
String msg = Res.get("account.notifications.priceAlert.message.msg",
currencyName,
formatter.formatMarketPrice(priceAsDouble, currencyCode),
formatter.getCurrencyPair(currencyCode));
BSFormatter.formatMarketPrice(priceAsDouble, currencyCode),
BSFormatter.getCurrencyPair(currencyCode));
MobileMessage message = new MobileMessage(Res.get("account.notifications.priceAlert.message.title", currencyName),
msg,
MobileMessageType.PRICE);
Expand Down

0 comments on commit 57d9bad

Please sign in to comment.