Percentage formatting

This commit is contained in:
Nicolás Sánchez 2025-01-03 23:25:08 -03:00
parent 5e018fe852
commit b624edb8a9
2 changed files with 21 additions and 5 deletions

View File

@ -1021,7 +1021,11 @@ public class HomeFragment extends Fragment {
if (binanceData.getFundsNeeded() != 0) {
binanceFundsPercentage = 100 - (binanceData.getFundsNeeded() - binanceData.getFundsAvailable()) / binanceData.getFundsNeeded() * 100;
}
String binanceFundsPercentageString = String.format(Locale.ROOT, "%.2f", binanceFundsPercentage) + "%";
String percentageFormat = "%.2f";
if (binanceFundsPercentage>=100) {
percentageFormat = "%.1f";
}
String binanceFundsPercentageString = String.format(Locale.ROOT, percentageFormat, binanceFundsPercentage) + "%";
exchange1Funds.setText(binanceFunds);
exchange1FundsPercentage.setText(binanceFundsPercentageString);
}
@ -1034,7 +1038,11 @@ public class HomeFragment extends Fragment {
if (gateioData.getFundsNeeded() != 0) {
gateioFundsPercentage = 100 - (gateioData.getFundsNeeded() - gateioData.getFundsAvailable()) / gateioData.getFundsNeeded() * 100;
}
String gateioFundsPercentageString = String.format(Locale.ROOT, "%.2f", gateioFundsPercentage) + "%";
String percentageFormat = "%.2f";
if (gateioFundsPercentage>=100) {
percentageFormat = "%.1f";
}
String gateioFundsPercentageString = String.format(Locale.ROOT, percentageFormat, gateioFundsPercentage) + "%";
exchange2Funds.setText(gateioFunds);
exchange2FundsPercentage.setText(gateioFundsPercentageString);
}
@ -1047,7 +1055,11 @@ public class HomeFragment extends Fragment {
if (kucoinData.getFundsNeeded() != 0) {
kucoinFundsPercentage = 100 - (kucoinData.getFundsNeeded() - kucoinData.getFundsAvailable()) / kucoinData.getFundsNeeded() * 100;
}
String kucoinFundsPercentageString = String.format(Locale.ROOT, "%.2f", kucoinFundsPercentage) + "%";
String percentageFormat = "%.2f";
if (kucoinFundsPercentage>=100) {
percentageFormat = "%.1f";
}
String kucoinFundsPercentageString = String.format(Locale.ROOT, percentageFormat, kucoinFundsPercentage) + "%";
exchange3Funds.setText(kucoinFunds);
exchange3FundsPercentage.setText(kucoinFundsPercentageString);
}
@ -1060,7 +1072,11 @@ public class HomeFragment extends Fragment {
if (okexData.getFundsNeeded() != 0) {
okexFundsPercentage = 100 - (okexData.getFundsNeeded() - okexData.getFundsAvailable()) / okexData.getFundsNeeded() * 100;
}
String okexFundsPercentageString = String.format(Locale.ROOT, "%.2f", okexFundsPercentage) + "%";
String percentageFormat = "%.2f";
if (okexFundsPercentage>=100) {
percentageFormat = "%.1f";
}
String okexFundsPercentageString = String.format(Locale.ROOT, percentageFormat, okexFundsPercentage) + "%";
exchange4Funds.setText(okexFunds);
exchange4FundsPercentage.setText(okexFundsPercentageString);
}