altosdroid: Check state.gps != null before using it
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TabLanded.java
index a95e914557592b8de54eadd8c90067cbc1121e1d..c346dc991763cdfec4e69a45ea1f0e9146ead798 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.altusmetrum.AltosDroid;
 
-import org.altusmetrum.altoslib_1.AltosState;
+import org.altusmetrum.altoslib_1.*;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -26,6 +26,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
+import android.location.Location;
 
 public class TabLanded extends Fragment implements AltosDroidTab {
        AltosDroid mAltosDroid;
@@ -68,13 +69,15 @@ public class TabLanded extends Fragment implements AltosDroidTab {
                mAltosDroid = null;
        }
 
-       public void update_ui(AltosState state) {
-               if (state.from_pad != null) {
-                       mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
-                       mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
+       public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
+               if (from_receiver != null) {
+                       mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
+                       mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
+               }
+               if (state.gps != null) {
+                       mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+                       mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
                }
-               mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
-               mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
                mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
                mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
                mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));