progress bar colors

This commit is contained in:
Nicolás Sánchez 2024-12-18 10:48:32 -03:00
parent 231fb297f8
commit d47567e226
5 changed files with 22 additions and 11 deletions

View File

@ -4,7 +4,7 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-12-17T22:52:32.286553137Z"> <DropdownSelection timestamp="2024-12-18T13:29:16.439093075Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/home/nicolas/.android/avd/Pixel_6_Pro_API_34.avd" /> <DeviceId pluginId="LocalEmulator" identifier="path=/home/nicolas/.android/avd/Pixel_6_Pro_API_34.avd" />

View File

@ -1,6 +1,8 @@
package com.example.dcav2gui.ui.exchanges.adapters; package com.example.dcav2gui.ui.exchanges.adapters;
import static java.lang.Math.abs; import static java.lang.Math.abs;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -66,11 +68,6 @@ 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()));
double breakEven = worker.getTotalAmountOfQuote()/worker.getTotalAmountOfBase();
if (worker.getPrice() > breakEven) {
price.setTextColor(Color.parseColor("#00A000"));
}
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);
@ -94,9 +91,20 @@ public class WorkerCardAdapter{
double progressBarPercentage = (worker.getPrice()-worker.getNextSoPrice())/(worker.getTakeProfitPrice()-worker.getNextSoPrice()); double progressBarPercentage = (worker.getPrice()-worker.getNextSoPrice())/(worker.getTakeProfitPrice()-worker.getNextSoPrice());
progressBar.setProgress((int) (progressBarPercentage * 100)); progressBar.setProgress((int) (progressBarPercentage * 100));
double breakEven = worker.getTotalAmountOfQuote()/worker.getTotalAmountOfBase();
if (!worker.isShort()) {
if (worker.getPrice() > breakEven) {
progressBar.setProgressTintList(ColorStateList.valueOf(Color.parseColor("#00A000")));
} else {
progressBar.setProgressTintList(ColorStateList.valueOf(Color.parseColor("#B00000")));
}
} else {
if (worker.getPrice() < breakEven) {
progressBar.setProgressTintList(ColorStateList.valueOf(Color.parseColor("#00A000")));
} else {
progressBar.setProgressTintList(ColorStateList.valueOf(Color.parseColor("#B00000")));
}
}
if (worker.isBoosted()) { if (worker.isBoosted()) {
workerCardIcon.setVisibility(View.VISIBLE); workerCardIcon.setVisibility(View.VISIBLE);

View File

@ -54,7 +54,7 @@
android:id="@+id/workerCardStatusString" android:id="@+id/workerCardStatusString"
android:layout_width="46dp" android:layout_width="46dp"
android:layout_height="24dp" android:layout_height="24dp"
android:text="LAST DEAL" android:text="@string/last_deal_notice"
android:textSize="8sp" android:textSize="8sp"
android:textStyle="bold" android:textStyle="bold"
android:textAlignment="center" android:textAlignment="center"
@ -65,6 +65,7 @@
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_flame" android:src="@drawable/ic_flame"
android:visibility="visible" android:visibility="visible"
android:contentDescription="@string/fire_icon_legend"
/> />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -112,7 +113,7 @@
android:max="100" android:max="100"
android:progress="50" android:progress="50"
android:layout_weight="1" android:layout_weight="1"
android:progressDrawable="@drawable/worker_progress_bar"/> android:progressDrawable="@drawable/worker_progress_bar" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -9,6 +9,7 @@
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="green">#FF008000</color> <color name="green">#FF008000</color>
<color name="red">#FFFF0000</color> <color name="red">#FFFF0000</color>
<color name="dark_red">#B00000</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="dark_yellow">#99991D</color>

View File

@ -81,4 +81,5 @@
<string name="loading_message">Querying data sources…</string> <string name="loading_message">Querying data sources…</string>
<string name="last_deal_notice">LAST DEAL</string> <string name="last_deal_notice">LAST DEAL</string>
<string name="autoswitch_notice">AUTO</string> <string name="autoswitch_notice">AUTO</string>
<string name="fire_icon_legend">Fire icon</string>
</resources> </resources>