@Override public void onApiConnected() { mMissionProxy = getMissionProxy(); mSelectedProxies.clear(); mSelectedProxies.addAll(mMissionProxy.selection.getSelected()); mSelectedItems.clear(); for (MissionItemProxy mip : mSelectedProxies) { mSelectedItems.add(mip.getMissionItem()); } final View view = getView(); if (view == null) return; List<MissionItemType> list = new LinkedList<MissionItemType>(Arrays.asList(MissionItemType.values())); if (mSelectedProxies.size() == 1) { final MissionItemProxy itemProxy = mSelectedProxies.get(0); final MissionItem currentItem = itemProxy.getMissionItem(); if (currentItem instanceof Survey) { list.clear(); list.add(MissionItemType.SURVEY); } else { list.remove(MissionItemType.SURVEY); } if ((currentItem instanceof StructureScanner)) { list.clear(); list.add(MissionItemType.STRUCTURE_SCANNER); } if (mMissionProxy.getItems().indexOf(itemProxy) != 0) { list.remove(MissionItemType.TAKEOFF); } if (mMissionProxy.getItems().indexOf(itemProxy) != (mMissionProxy.getItems().size() - 1)) { list.remove(MissionItemType.LAND); list.remove(MissionItemType.RETURN_TO_LAUNCH); } if (currentItem instanceof MissionItem.Command) { list.remove(MissionItemType.LAND); list.remove(MissionItemType.SPLINE_WAYPOINT); list.remove(MissionItemType.CIRCLE); list.remove(MissionItemType.REGION_OF_INTEREST); list.remove(MissionItemType.WAYPOINT); list.remove(MissionItemType.STRUCTURE_SCANNER); } final TextView waypointIndex = (TextView) view.findViewById(R.id.WaypointIndex); if (waypointIndex != null) { final int itemOrder = mMissionProxy.getOrder(itemProxy); waypointIndex.setText(String.valueOf(itemOrder)); } final TextView distanceView = (TextView) view.findViewById(R.id.DistanceValue); if (distanceView != null) { distanceView.setText( getLengthUnitProvider() .boxBaseValueToTarget(mMissionProxy.getDistanceFromLastWaypoint(itemProxy)) .toString()); } final TextView distanceLabelView = (TextView) view.findViewById(R.id.DistanceLabel); if (distanceLabelView != null) { distanceLabelView.setVisibility(View.VISIBLE); } } else if (mSelectedProxies.size() > 1) { // Remove the mission item types that don't apply to multiple items. list.removeAll(typeWithNoMultiEditSupport); } else { // Invalid state. We should not have been able to get here. throw new IllegalStateException( "Mission Detail Fragment cannot be shown when no " + "mission items is selected."); } commandAdapter = new AdapterMissionItems( getActivity(), android.R.layout.simple_list_item_1, list.toArray(new MissionItemType[list.size()])); typeSpinner = (SpinnerSelfSelect) view.findViewById(R.id.spinnerWaypointType); typeSpinner.setAdapter(commandAdapter); typeSpinner.setOnSpinnerItemSelectedListener(this); }
protected MissionItem(Parcel in) { this.type = MissionItemType.values()[in.readInt()]; }