Fixed java lint errors
This commit is contained in:
+5
-4
@@ -220,10 +220,10 @@ public class PortfolioFragment
|
||||
List<WalletListItemModel> walletListItemModelList = new ArrayList<>();
|
||||
String tokensPath = ERCTokenRegistryFactory.getInstance().getTokensIconsLocation();
|
||||
for (ErcToken userAsset : userAssets) {
|
||||
String currentAssetSymbol = userAsset.symbol.toLowerCase();
|
||||
Double fiatBalance = perTokenFiatSum.getOrDefault(currentAssetSymbol, 0.0d);
|
||||
String currentAssetSymbol = userAsset.symbol.toLowerCase(Locale.getDefault());
|
||||
Double fiatBalance = Utils.getOrDefault(perTokenFiatSum, currentAssetSymbol, 0.0d);
|
||||
String fiatBalanceString = String.format(Locale.getDefault(), "$%,.2f", fiatBalance);
|
||||
Double cryptoBalance = perTokenCryptoSum.getOrDefault(currentAssetSymbol, 0.0d);
|
||||
Double cryptoBalance = Utils.getOrDefault(perTokenCryptoSum, currentAssetSymbol, 0.0d);
|
||||
String cryptoBalanceString =
|
||||
String.format(Locale.getDefault(), "%.4f %s", cryptoBalance, userAsset.symbol);
|
||||
|
||||
@@ -286,7 +286,8 @@ public class PortfolioFragment
|
||||
String chainId = Utils.getNetworkConst(getActivity(), chainName);
|
||||
portfolioHelper.setChainId(chainId);
|
||||
portfolioHelper.calculateBalances(() -> {
|
||||
final String fiatSumString = String.format(Locale.getDefault(), "$%,.2f", portfolioHelper.getTotalFiatSum());
|
||||
final String fiatSumString =
|
||||
String.format(Locale.getDefault(), "$%,.2f", portfolioHelper.getTotalFiatSum());
|
||||
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
|
||||
mBalance.setText(fiatSumString);
|
||||
mBalance.invalidate();
|
||||
|
||||
@@ -17,9 +17,11 @@ import org.chromium.brave_wallet.mojom.ErcToken;
|
||||
import org.chromium.brave_wallet.mojom.EthJsonRpcController;
|
||||
import org.chromium.brave_wallet.mojom.KeyringController;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.AsyncUtils;
|
||||
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PortfolioHelper {
|
||||
private static String TAG = "PortfolioHelper";
|
||||
@@ -81,7 +83,8 @@ public class PortfolioHelper {
|
||||
ArrayList<AsyncUtils.GetPriceResponseContext> pricesContexts =
|
||||
new ArrayList<AsyncUtils.GetPriceResponseContext>();
|
||||
for (ErcToken userAsset : mUserAssets) {
|
||||
String[] fromAssets = new String[] {userAsset.symbol.toLowerCase()};
|
||||
String[] fromAssets =
|
||||
new String[] {userAsset.symbol.toLowerCase(Locale.getDefault())};
|
||||
String[] toAssets = new String[] {"usd"};
|
||||
|
||||
AsyncUtils.GetPriceResponseContext priceContext =
|
||||
@@ -110,7 +113,8 @@ public class PortfolioHelper {
|
||||
return;
|
||||
}
|
||||
tokenToUsdRatios.put(
|
||||
priceContext.prices[0].fromAsset.toLowerCase(), usdPerToken);
|
||||
priceContext.prices[0].fromAsset.toLowerCase(Locale.getDefault()),
|
||||
usdPerToken);
|
||||
}
|
||||
|
||||
mKeyringController.getDefaultKeyringInfo(keyringInfo -> {
|
||||
@@ -150,9 +154,10 @@ public class PortfolioHelper {
|
||||
|
||||
balancesMultiResponse.setWhenAllCompletedAction(() -> {
|
||||
for (AsyncUtils.GetBalanceResponseBaseContext context : contexts) {
|
||||
String currentAssetSymbol = context.userAsset.symbol.toLowerCase();
|
||||
Double usdPerThisToken =
|
||||
tokenToUsdRatios.getOrDefault(currentAssetSymbol, 0.0d);
|
||||
String currentAssetSymbol =
|
||||
context.userAsset.symbol.toLowerCase(Locale.getDefault());
|
||||
Double usdPerThisToken = Utils.getOrDefault(
|
||||
tokenToUsdRatios, currentAssetSymbol, 0.0d);
|
||||
|
||||
Double thisBalanceCryptoPart =
|
||||
context.success ? fromHexWei(context.balance) : 0.0d;
|
||||
@@ -160,13 +165,14 @@ public class PortfolioHelper {
|
||||
Double thisBalanceFiatPart =
|
||||
usdPerThisToken * thisBalanceCryptoPart;
|
||||
|
||||
Double prevThisTokenCryptoSum =
|
||||
mPerTokenCryptoSum.getOrDefault(currentAssetSymbol, 0.0d);
|
||||
Double prevThisTokenCryptoSum = Utils.getOrDefault(
|
||||
mPerTokenCryptoSum, currentAssetSymbol, 0.0d);
|
||||
|
||||
mPerTokenCryptoSum.put(currentAssetSymbol,
|
||||
prevThisTokenCryptoSum + thisBalanceCryptoPart);
|
||||
|
||||
Double prevThisTokenFiatSum =
|
||||
mPerTokenFiatSum.getOrDefault(currentAssetSymbol, 0.0d);
|
||||
Double prevThisTokenFiatSum = Utils.getOrDefault(
|
||||
mPerTokenFiatSum, currentAssetSymbol, 0.0d);
|
||||
mPerTokenFiatSum.put(currentAssetSymbol,
|
||||
prevThisTokenFiatSum + thisBalanceFiatPart);
|
||||
|
||||
|
||||
@@ -602,4 +602,13 @@ public class Utils {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
public static Double getOrDefault(
|
||||
HashMap<String, Double> map, String key, Double defaultValue) {
|
||||
// Can't use java.util.HashMap#getOrDefault with API level 21
|
||||
if (map.containsKey(key)) {
|
||||
return map.get(key);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user