X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosDroid.java;h=18f364fa5239725df6a5057c2a38715e1527cdfc;hb=ff332e640b27c6be37dabef58ebac350ac2347b2;hp=3715c3f9600a4d1d06b55c5f0efb08e3f81173de;hpb=e4b6fc3238ad9911fd40ef25accf82a401cb190f;p=fw%2Faltos diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 3715c3f9..18f364fa 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -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() { @@ -265,6 +265,8 @@ public class AltosDroid extends FragmentActivity { static String pos(double p, String pos, String neg) { String h = pos; + if (p == AltosRecord.MISSING) + return ""; if (p < 0) { h = neg; p = -p; @@ -274,6 +276,18 @@ public class AltosDroid extends FragmentActivity { return String.format("%d°%9.4f\" %s", deg, min, h); } + static String number(String format, double value) { + if (value == AltosRecord.MISSING) + return ""; + return String.format(format, value); + } + + static String integer(String format, int value) { + if (value == AltosRecord.MISSING) + return ""; + return String.format(format, value); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);