diff --git a/androidgcs/res/layout/system_alarms.xml b/androidgcs/res/layout/system_alarms.xml index e67990427..b1a830ccd 100644 --- a/androidgcs/res/layout/system_alarms.xml +++ b/androidgcs/res/layout/system_alarms.xml @@ -5,11 +5,17 @@ android:layout_gravity="center" > + + > objects) { @@ -326,7 +328,8 @@ public abstract class ObjectManagerActivity extends Activity { } } ; - void addOnConnectionListenerFragment(ObjectManagerFragment frag) { + + public void addOnConnectionListenerFragment(ObjectManagerFragment frag) { connectionListeners.addObserver(new OnConnectionListener(frag)); if (DEBUG) Log.d(TAG, "Connecting " + frag + " there are now " + connectionListeners.countObservers()); if (mConnected) diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerFragment.java b/androidgcs/src/org/openpilot/androidgcs/fragments/ObjectManagerFragment.java similarity index 93% rename from androidgcs/src/org/openpilot/androidgcs/ObjectManagerFragment.java rename to androidgcs/src/org/openpilot/androidgcs/fragments/ObjectManagerFragment.java index 768f178c2..0ddd7a97e 100644 --- a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerFragment.java +++ b/androidgcs/src/org/openpilot/androidgcs/fragments/ObjectManagerFragment.java @@ -24,8 +24,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package org.openpilot.androidgcs; +package org.openpilot.androidgcs.fragments; +import org.openpilot.androidgcs.ObjectManagerActivity; import org.openpilot.uavtalk.UAVObject; import org.openpilot.uavtalk.UAVObjectManager; @@ -74,12 +75,12 @@ public class ObjectManagerFragment extends Fragment { // The below methods should all be called by the parent activity at the appropriate times - protected void onOPConnected(UAVObjectManager objMngr) { + public void onOPConnected(UAVObjectManager objMngr) { this.objMngr = objMngr; if (DEBUG) Log.d(TAG,"onOPConnected"); } - protected void onOPDisconnected() { + public void onOPDisconnected() { objMngr = null; if (DEBUG) Log.d(TAG,"onOPDisconnected"); } @@ -87,7 +88,7 @@ public class ObjectManagerFragment extends Fragment { /** * Called whenever any objects subscribed to via registerObjects */ - protected void objectUpdated(UAVObject obj) { + public void objectUpdated(UAVObject obj) { } diff --git a/androidgcs/src/org/openpilot/androidgcs/PFD.java b/androidgcs/src/org/openpilot/androidgcs/fragments/PFD.java similarity index 78% rename from androidgcs/src/org/openpilot/androidgcs/PFD.java rename to androidgcs/src/org/openpilot/androidgcs/fragments/PFD.java index fa4480180..ec265fe6e 100644 --- a/androidgcs/src/org/openpilot/androidgcs/PFD.java +++ b/androidgcs/src/org/openpilot/androidgcs/fragments/PFD.java @@ -22,11 +22,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package org.openpilot.androidgcs; +package org.openpilot.androidgcs.fragments; +import org.openpilot.androidgcs.AttitudeView; +import org.openpilot.androidgcs.R; import org.openpilot.uavtalk.UAVObject; import org.openpilot.uavtalk.UAVObjectManager; +import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -65,18 +68,25 @@ public class PFD extends ObjectManagerFragment { * Called whenever any objects subscribed to via registerObjects */ @Override - protected void objectUpdated(UAVObject obj) { + public void objectUpdated(UAVObject obj) { if (DEBUG) Log.d(TAG, "Updated"); double pitch = obj.getField("Pitch").getDouble(); double roll = obj.getField("Roll").getDouble(); - AttitudeView attitude = (AttitudeView) getActivity().findViewById( - R.id.attitude_view); - attitude.setRoll(roll); - attitude.setPitch(pitch); - attitude.invalidate(); + // TODO: These checks, while sensible, are necessary because the + // callbacks aren't + // removed when we switch to different activities sharing this fragment + Activity parent = getActivity(); + AttitudeView attitude = null; + if (parent != null) + attitude = (AttitudeView) parent.findViewById(R.id.attitude_view); + if (attitude != null) { + attitude.setRoll(roll); + attitude.setPitch(pitch); + attitude.invalidate(); + } } diff --git a/androidgcs/src/org/openpilot/androidgcs/SystemAlarmsFragment.java b/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java similarity index 96% rename from androidgcs/src/org/openpilot/androidgcs/SystemAlarmsFragment.java rename to androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java index a7d0ce67e..e311e7249 100644 --- a/androidgcs/src/org/openpilot/androidgcs/SystemAlarmsFragment.java +++ b/androidgcs/src/org/openpilot/androidgcs/fragments/SystemAlarmsFragment.java @@ -21,10 +21,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package org.openpilot.androidgcs; +package org.openpilot.androidgcs.fragments; import java.util.List; +import org.openpilot.androidgcs.R; import org.openpilot.uavtalk.UAVObject; import org.openpilot.uavtalk.UAVObjectField; import org.openpilot.uavtalk.UAVObjectManager; @@ -67,7 +68,7 @@ public class SystemAlarmsFragment extends ObjectManagerFragment { * Called whenever any objects subscribed to via registerObjects */ @Override - protected void objectUpdated(UAVObject obj) { + public void objectUpdated(UAVObject obj) { if (DEBUG) Log.d(TAG, "Updated"); if (obj.getName().compareTo("SystemAlarms") == 0) {