colored percentage-to-profit in worker_card

This commit is contained in:
Nicolás Sánchez 2024-12-18 08:54:15 -03:00
parent 6c79979f72
commit 9371aea39d
4 changed files with 26 additions and 19 deletions

View File

@ -35,6 +35,7 @@ public class BinanceFragment extends Fragment {
View root = binding.getRoot(); View root = binding.getRoot();
//Initialize status bar //Initialize status bar
//Maybe instead of editing the status bar, edit the appbar at mobile_navigation.xml?
statusBar = root.findViewById(R.id.binance_status_bar); statusBar = root.findViewById(R.id.binance_status_bar);
binanceViewModel = new ViewModelProvider(this).get(BinanceViewModel.class); binanceViewModel = new ViewModelProvider(this).get(BinanceViewModel.class);
@ -45,7 +46,6 @@ public class BinanceFragment extends Fragment {
if (workerDataList != null) { if (workerDataList != null) {
WorkerCardAdapter.populateStatusBar(statusBar, workerDataList); WorkerCardAdapter.populateStatusBar(statusBar, workerDataList);
workerCardAdapter.updateData(workerDataList); workerCardAdapter.updateData(workerDataList);
} }
}); });

View File

@ -68,8 +68,21 @@ public class WorkerCardAdapter{
nextSoPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getNextSoPrice())); nextSoPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getNextSoPrice()));
takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice())); takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice()));
String percentageToDisplay = String.format(Locale.ROOT, "%.2f",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)+"%";
percentage.setText(percentageToDisplay); percentage.setText(percentageToDisplay);
if (percentageToProfit<1) {
//Green
percentage.setTextColor(Color.parseColor("#006A00"));
} else if (percentageToProfit>20) {
//Red
percentage.setTextColor(Color.parseColor("#FFFF0000"));
} else if (percentageToProfit>10) {
//Yellow
percentage.setTextColor(Color.parseColor("#FFA500"));
} else {
percentage.setTextColor(Color.parseColor("#FF424242"));
}
String safetyOrdersToDisplay = worker.getAmountOfSafetyOrders()-1 + "/" + worker.getMaxSafetyOrders(); String safetyOrdersToDisplay = worker.getAmountOfSafetyOrders()-1 + "/" + worker.getMaxSafetyOrders();
safetyOrders.setText(safetyOrdersToDisplay); safetyOrders.setText(safetyOrdersToDisplay);
@ -81,6 +94,8 @@ public class WorkerCardAdapter{
double breakEven = worker.getTotalAmountOfQuote()/worker.getTotalAmountOfBase(); double breakEven = worker.getTotalAmountOfQuote()/worker.getTotalAmountOfBase();
if (worker.isBoosted()) { if (worker.isBoosted()) {
workerCardIcon.setVisibility(View.VISIBLE); workerCardIcon.setVisibility(View.VISIBLE);
} else { } else {

View File

@ -11,8 +11,9 @@
<color name="red">#FFFF0000</color> <color name="red">#FFFF0000</color>
<color name="blue">#FF0000FF</color> <color name="blue">#FF0000FF</color>
<color name="yellow">#FFFFFF00</color> <color name="yellow">#FFFFFF00</color>
<color name="dark_yellow">#99991D</color>
<color name="grey">#FF424242</color> <color name="grey">#FF424242</color>
<color name= "light_grey">#979797</color> <color name="light_grey">#979797</color>
<color name="orange">#FFA500</color> <color name="orange">#FFA500</color>
<color name="dark_cyan">#008B8B</color> <color name="dark_cyan">#008B8B</color>
<color name="dark_green">#006A00</color> <color name="dark_green">#006A00</color>

View File

@ -63,29 +63,20 @@
<string name="exchange_3_name" translatable="false">KuCoin</string> <string name="exchange_3_name" translatable="false">KuCoin</string>
<string name="exchange_4_name" translatable="false">OKX</string> <string name="exchange_4_name" translatable="false">OKX</string>
<string name="exchange_funds_example" translatable="false">35203.20/65535.20</string> <string name="exchange_funds_example" translatable="false"> </string>
<string name="exchange_funds_percentage_example" translatable="false">169%</string> <string name="exchange_funds_percentage_example" translatable="false"> </string>
<string name="exchange_workers_online_example" translatable="false">20</string> <string name="exchange_workers_online_example" translatable="false"> </string>
<string name="exchange_workers_long_short_example" translatable="false">20/20</string> <string name="exchange_workers_long_short_example" translatable="false"> </string>
<string name="exchange_separator" translatable="false">/</string> <string name="exchange_separator" translatable="false">/</string>
<string name="exchange_online_label">online</string> <string name="exchange_online_label">online</string>
<string name="last_trades_label">Last trades</string> <string name="last_trades_label">Last trades</string>
<string name="last_trades_example" translatable="false">[2024/12/11 10:41:14] LUMIA/USDT | 2.29 USDT | Binance <string name="last_trades_example" translatable="false"> </string>
[2024/12/11 10:10:18] HARD/USDT | 1.4 USDT | Binance
[2024/12/11 09:26:51] LUMIA/USDT | 1.66 USDT | Binance
[2024/12/11 09:17:42] TROY/USDT | 0.83 USDT | Binance
[2024/12/11 08:37:38] PROS/USDT | 0.81 USDT | Binance
[2024/12/11 08:34:17] HBAR/USDT | 1.07 USDT | Binance
[2024/12/11 08:28:29] HBAR/USDT | 0.34 USDT | Binance
[2024/12/11 07:52:58] HBAR/USDT | 0.34 USDT | Binance
[2024/12/11 07:44:02] NEIRO/USDT | 0.27 USDT | Binance
[2024/12/11 07:09:51] TROY/USDT | 1.71 USDT | Binance</string>
<string name="log_example" translatable="false">[2024/12/11 10:41:34] Everything is horrible\n[2024/12/11 10:41:34] Things are going south very rapidly\n[2024/12/11 10:41:34] Can\'t imagine how to even try to fix this\n[2024/12/11 10:41:34] Oh lord, take me now\n[2024/12/11 10:41:34] What the hell is that?!?!\n[2024/12/11 10:41:34] Oh dear\n[2024/12/11 10:41:34] What is that small red light?</string> <string name="log_example" translatable="false"> </string>
<string name="exchange_1_log_title" translatable="false">Binance log</string> <string name="exchange_1_log_title" translatable="false">Binance log</string>
<string name="exchange_2_log_title" translatable="false">Gate.io log</string> <string name="exchange_2_log_title" translatable="false">Gate.io log</string>
<string name="exchange_3_log_title" translatable="false">Kucoin log</string> <string name="exchange_3_log_title" translatable="false">Kucoin log</string>
<string name="exchange_4_log_title" translatable="false">OKX log</string> <string name="exchange_4_log_title" translatable="false">OKX log</string>
<string name="loading_message">Querying data sources...</string> <string name="loading_message">Querying data sources…</string>
</resources> </resources>