altosdroid: Auto tab changing
authorMike Beattie <mike@ethernal.org>
Thu, 7 Mar 2013 08:37:51 +0000 (21:37 +1300)
committerMike Beattie <mike@ethernal.org>
Thu, 7 Mar 2013 08:37:51 +0000 (21:37 +1300)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java

index 2f98b64bfffeb0eb80a808911bb33132136c4268..63043abd503468e9e1730cf5ebbcd0290f45a8c8 100644 (file)
@@ -197,6 +197,22 @@ public class AltosDroid extends FragmentActivity {
        }
 
        void update_ui(AltosState state) {
        }
 
        void update_ui(AltosState state) {
+               if (saved_state != null) {
+                       if (saved_state.state != state.state) {
+                               String currentTab = mTabHost.getCurrentTabTag();
+                               switch (state.state) {
+                               case AltosLib.ao_flight_boost:
+                                       if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("ascent");
+                                       break;
+                               case AltosLib.ao_flight_drogue:
+                                       if (currentTab.equals("ascent")) mTabHost.setCurrentTabByTag("descent");
+                                       break;
+                               case AltosLib.ao_flight_landed:
+                                       if (currentTab.equals("descent")) mTabHost.setCurrentTabByTag("landed");
+                                       break;
+                               }
+                       }
+               }
                saved_state = state;
 
                mCallsignView.setText(state.data.callsign);
                saved_state = state;
 
                mCallsignView.setText(state.data.callsign);