Percentage formatting
This commit is contained in:
parent
5e018fe852
commit
b624edb8a9
|
|
@ -100,7 +100,7 @@ public class WorkerCardAdapter{
|
||||||
takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice()));
|
takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice()));
|
||||||
|
|
||||||
double percentageToProfit = abs(worker.getTakeProfitPrice()- worker.getPrice())/worker.getPrice()*100;
|
double percentageToProfit = abs(worker.getTakeProfitPrice()- worker.getPrice())/worker.getPrice()*100;
|
||||||
String percentageToDisplay = String.format(Locale.ROOT, "%.2f",percentageToProfit)+"%";
|
String percentageToDisplay = String.format(Locale.ROOT, "%.2f", percentageToProfit)+"%";
|
||||||
percentage.setText(percentageToDisplay);
|
percentage.setText(percentageToDisplay);
|
||||||
if (percentageToProfit<1) {
|
if (percentageToProfit<1) {
|
||||||
//Green
|
//Green
|
||||||
|
|
|
||||||
|
|
@ -1021,7 +1021,11 @@ public class HomeFragment extends Fragment {
|
||||||
if (binanceData.getFundsNeeded() != 0) {
|
if (binanceData.getFundsNeeded() != 0) {
|
||||||
binanceFundsPercentage = 100 - (binanceData.getFundsNeeded() - binanceData.getFundsAvailable()) / binanceData.getFundsNeeded() * 100;
|
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);
|
exchange1Funds.setText(binanceFunds);
|
||||||
exchange1FundsPercentage.setText(binanceFundsPercentageString);
|
exchange1FundsPercentage.setText(binanceFundsPercentageString);
|
||||||
}
|
}
|
||||||
|
|
@ -1034,7 +1038,11 @@ public class HomeFragment extends Fragment {
|
||||||
if (gateioData.getFundsNeeded() != 0) {
|
if (gateioData.getFundsNeeded() != 0) {
|
||||||
gateioFundsPercentage = 100 - (gateioData.getFundsNeeded() - gateioData.getFundsAvailable()) / gateioData.getFundsNeeded() * 100;
|
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);
|
exchange2Funds.setText(gateioFunds);
|
||||||
exchange2FundsPercentage.setText(gateioFundsPercentageString);
|
exchange2FundsPercentage.setText(gateioFundsPercentageString);
|
||||||
}
|
}
|
||||||
|
|
@ -1047,7 +1055,11 @@ public class HomeFragment extends Fragment {
|
||||||
if (kucoinData.getFundsNeeded() != 0) {
|
if (kucoinData.getFundsNeeded() != 0) {
|
||||||
kucoinFundsPercentage = 100 - (kucoinData.getFundsNeeded() - kucoinData.getFundsAvailable()) / kucoinData.getFundsNeeded() * 100;
|
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);
|
exchange3Funds.setText(kucoinFunds);
|
||||||
exchange3FundsPercentage.setText(kucoinFundsPercentageString);
|
exchange3FundsPercentage.setText(kucoinFundsPercentageString);
|
||||||
}
|
}
|
||||||
|
|
@ -1060,7 +1072,11 @@ public class HomeFragment extends Fragment {
|
||||||
if (okexData.getFundsNeeded() != 0) {
|
if (okexData.getFundsNeeded() != 0) {
|
||||||
okexFundsPercentage = 100 - (okexData.getFundsNeeded() - okexData.getFundsAvailable()) / okexData.getFundsNeeded() * 100;
|
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);
|
exchange4Funds.setText(okexFunds);
|
||||||
exchange4FundsPercentage.setText(okexFundsPercentageString);
|
exchange4FundsPercentage.setText(okexFundsPercentageString);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue