altoslib: Finish AltosState changes. Update version number.
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TabAscent.java
index de3bc3d29f5cefd8e5e16e2e643eff1017be410e..69bc68c95f6575b99fe95e09c56b5f909d7c8382 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.altusmetrum.AltosDroid;
 
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -86,22 +86,27 @@ public class TabAscent extends Fragment implements AltosDroidTab {
        }
 
        public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
-               mHeightView.setText(String.format("%6.0f m", state.height));
-               mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
-               mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
-               mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
-               mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
-               mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
-
-               if (state.gps != null) {
-                       mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
-                       mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+               if (state != null) {
+                       mHeightView.setText(AltosDroid.number("%6.0f m", state.height));
+                       mMaxHeightView.setText(AltosDroid.number("%6.0f m", state.max_height));
+                       mSpeedView.setText(AltosDroid.number("%6.0f m/s", state.speed()));
+                       mMaxSpeedView.setText(AltosDroid.number("%6.0f m/s", state.max_speed()));
+                       mAccelView.setText(AltosDroid.number("%6.0f m/s²", state.acceleration));
+                       mMaxAccelView.setText(AltosDroid.number("%6.0f m/s²", state.max_acceleration));
+
+                       if (state.gps != null) {
+                               mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+                               mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+                       } else {
+                               mLatitudeView.setText("");
+                               mLongitudeView.setText("");
+                       }
+
+                       mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
+                       mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosLib.MISSING);
+
+                       mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
+                       mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosLib.MISSING);
                }
-
-               mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
-               mApogeeLights.set(state.drogue_sense > 3.2);
-
-               mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
-               mMainLights.set(state.main_sense > 3.2);
        }
 }