From 91a8186e54fac9fb3a2f8e8c339af94a4a3d9f94 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 10 Aug 2012 02:01:27 -0500 Subject: [PATCH] AndroidGCS: Because right now the object updated callbacks are not diconnected when an activity goes away we need to check the view is valid when processing the object callbacks. --- .../androidgcs/fragments/SystemAlarmsFragment.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java b/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java index e311e7249..1bcbfee63 100644 --- a/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java +++ b/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java @@ -30,6 +30,7 @@ import org.openpilot.uavtalk.UAVObject; import org.openpilot.uavtalk.UAVObjectField; import org.openpilot.uavtalk.UAVObjectManager; +import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -72,7 +73,16 @@ public class SystemAlarmsFragment extends ObjectManagerFragment { if (DEBUG) Log.d(TAG, "Updated"); if (obj.getName().compareTo("SystemAlarms") == 0) { + Activity activity = getActivity(); + if (activity == null) { + // TODO: Need to unregister all the callbacks + return; + } TextView alarms = (TextView) getActivity().findViewById(R.id.system_alarms_fragment_field); + if (alarms == null) { + // TODO: Need to figure out how to unregister all the callbacks + return; + } UAVObjectField a = obj.getField("Alarm"); List names = a.getElementNames(); String contents = new String();