@Override
  public void onSpinnerItemSelected(Spinner spinner, int position) {
    final MissionItemType selectedType = commandAdapter.getItem(position);

    try {
      if (mSelectedProxies.isEmpty()) return;

      final List<Pair<MissionItemProxy, MissionItemProxy>> updatesList =
          new ArrayList<Pair<MissionItemProxy, MissionItemProxy>>(mSelectedProxies.size());

      for (MissionItemProxy missionItemProxy : mSelectedProxies) {
        final MissionItem oldItem = missionItemProxy.getMissionItem();
        if (oldItem.getType() != selectedType) {
          final MissionItem newItem = selectedType.getNewItem();

          if (oldItem instanceof MissionItem.SpatialItem
              && newItem instanceof MissionItem.SpatialItem) {
            ((MissionItem.SpatialItem) newItem)
                .setCoordinate(((MissionItem.SpatialItem) oldItem).getCoordinate());
          }

          updatesList.add(
              Pair.create(missionItemProxy, new MissionItemProxy(mMissionProxy, newItem)));
        }
      }

      if (!updatesList.isEmpty()) {
        mListener.onWaypointTypeChanged(selectedType, updatesList);
        dismiss();
      }
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    }
  }
示例#2
0
    @Override
    public void onMapClick(LatLong point) {
      if (missionProxy == null) return;

      // If an mission item is selected, unselect it.
      missionProxy.selection.clearSelection();

      if (selectedType == null) return;

      BaseSpatialItem spatialItem = (BaseSpatialItem) selectedType.getNewItem();
      missionProxy.addSpatialWaypoint(spatialItem, point);
    }