Skip to content

Commit

Permalink
Home: fix nanostatus layout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Aug 26, 2024
1 parent 2759407 commit 7cbe18f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class NanoStatus {
public final ObservableField<String> watch = new ObservableField<>();
public final ObservableField<SpannableString> color_watch = new ObservableField<>();

public static String debugStringStatic = null;
public String debugString = null;

private static String lastException = "";

public NanoStatus(final String parameter, final int freqMs) {
Expand All @@ -61,6 +64,9 @@ public NanoStatus(final String parameter, final int freqMs) {
running = true;
startRefresh();
}
if (debugStringStatic != null) {
debugString = debugStringStatic + " " + parameter;
}
}

public void setRunning(final boolean state) {
Expand Down Expand Up @@ -141,6 +147,9 @@ private static SpannableString getLocalOrRemoteSensorExpiry() {

static SpannableString collectorNano(final Class<?> service) {
if (service != null) {
if (debugStringStatic != null) {
return new SpannableString(debugStringStatic + " " + service.getSimpleName());
}
try {
try {
return (SpannableString) cache.get(service).invoke(null);
Expand Down Expand Up @@ -203,6 +212,10 @@ public static SpannableString getRemote() {
}

public static SpannableString getRemote(final String prefix) {
if (debugStringStatic != null) {
return new SpannableString(debugStringStatic + " " + prefix);
}

// TODO apply timeout?
try {
val result = PersistentStore.getString(REMOTE_COLLECTOR_STATUS_STORE + prefix);
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="horizontal"
app:showIfTrue="@{safeUnbox(vs.included[`collector_nano_status`])}">
app:showIfTrue="@{(safeUnbox(vs.included[`collector_nano_status`]) || safeUnbox(vs.included[`sensor_expiry`]))}">


<TextView
Expand All @@ -544,17 +544,20 @@
android:layout_marginTop="2dp"
android:layout_marginStart="5dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@{nano.color_watch, default=`Nano Status`}"
app:showIfTrue="@{nano.color_watch.length() > 0}"/>
app:showIfTrue="@{(safeUnbox(vs.included[`collector_nano_status`] &amp;&amp; nano.color_watch.length() > 0))}"/>

<TextView
android:id="@+id/ExpiryStatusText"
android:layout_width="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginStart="5dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="5dp"
android:text="@{expiry.color_watch, default=`Expiry Status`}"
app:showIfTrue="@{(safeUnbox(vs.included[`sensor_expiry`])) &amp;&amp; (expiry.color_watch.length() > 0)}"/>
app:showIfTrue="@{(safeUnbox(vs.included[`sensor_expiry`]) &amp;&amp; (expiry.color_watch.length() > 0))}"/>

</LinearLayout>

Expand Down

0 comments on commit 7cbe18f

Please sign in to comment.