Merge branch 'master' into droid-gps
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosDroid.java
index 3715c3f9600a4d1d06b55c5f0efb08e3f81173de..5ce6f81069eae5bb7222f9d4c447ce211d8b28e1 100644 (file)
@@ -126,7 +126,6 @@ public class AltosDroid extends FragmentActivity {
                                        ad.mTitle.setText(R.string.title_connected_to);
                                        ad.mTitle.append(str);
                                        Toast.makeText(ad.getApplicationContext(), "Connected to " + str, Toast.LENGTH_SHORT).show();
-                                       ad.mAltosVoice.speak("Connected");
                                        break;
                                case TelemetryService.STATE_CONNECTING:
                                        ad.mTitle.setText(R.string.title_connecting);
@@ -206,13 +205,11 @@ public class AltosDroid extends FragmentActivity {
 
        void set_location(Location location) {
                saved_location = location;
-               if (saved_state != null) {
-                       update_ui(saved_state);
-               }
+               update_ui(saved_state);
        }
 
        void update_ui(AltosState state) {
-               if (saved_state != null) {
+               if (state != null && saved_state != null) {
                        if (saved_state.state != state.state) {
                                String currentTab = mTabHost.getCurrentTabTag();
                                switch (state.state) {
@@ -232,7 +229,7 @@ public class AltosDroid extends FragmentActivity {
 
                AltosGreatCircle from_receiver = null;
 
-               if (saved_location != null && state.gps != null && state.gps.locked) {
+               if (state != null && saved_location != null && state.gps != null && state.gps.locked) {
                        double altitude = 0;
                        if (saved_location.hasAltitude())
                                altitude = saved_location.getAltitude();
@@ -244,16 +241,19 @@ public class AltosDroid extends FragmentActivity {
                                                             state.gps.alt);
                }
 
-               mCallsignView.setText(state.data.callsign);
-               mSerialView.setText(String.format("%d", state.data.serial));
-               mFlightView.setText(String.format("%d", state.data.flight));
-               mStateView.setText(state.data.state());
-               mRSSIView.setText(String.format("%d", state.data.rssi));
+               if (state != null) {
+                       mCallsignView.setText(state.data.callsign);
+                       mSerialView.setText(String.format("%d", state.data.serial));
+                       mFlightView.setText(String.format("%d", state.data.flight));
+                       mStateView.setText(state.data.state());
+                       mRSSIView.setText(String.format("%d", state.data.rssi));
+               }
 
                for (AltosDroidTab mTab : mTabs)
                        mTab.update_ui(state, from_receiver, saved_location);
 
-               mAltosVoice.tell(state);
+               if (state != null)
+                       mAltosVoice.tell(state);
        }
 
        private void onTimerTick() {