public void setupLocalViews(View view) {
    cameraSpinner = (SpinnerSelfSelect) view.findViewById(id.cameraFileSpinner);
    footprintCheckBox = (CheckBox) view.findViewById(id.CheckBoxFootprints);

    angleView = (SeekBarWithText) view.findViewById(id.angleView);
    overlapView = (SeekBarWithText) view.findViewById(id.overlapView);
    sidelapView = (SeekBarWithText) view.findViewById(id.sidelapView);
    altitudeView = (SeekBarWithText) view.findViewById(id.altitudeView);

    innerWPsCheckbox = (CheckBox) view.findViewById(id.checkBoxInnerWPs);

    areaTextView = (TextView) view.findViewById(id.areaTextView);
    distanceBetweenLinesTextView = (TextView) view.findViewById(id.distanceBetweenLinesTextView);
    footprintTextView = (TextView) view.findViewById(id.footprintTextView);
    groundResolutionTextView = (TextView) view.findViewById(id.groundResolutionTextView);
    distanceTextView = (TextView) view.findViewById(id.distanceTextView);
    numberOfPicturesView = (TextView) view.findViewById(id.numberOfPicturesTextView);
    numberOfStripsView = (TextView) view.findViewById(id.numberOfStripsTextView);
    lengthView = (TextView) view.findViewById(id.lengthTextView);

    cameraAdapter =
        new CamerasAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item);
    cameraSpinner.setAdapter(cameraAdapter);

    footprintCheckBox.setOnClickListener(this);
    angleView.setOnChangedListener(this);
    altitudeView.setOnChangedListener(this);
    overlapView.setOnChangedListener(this);
    sidelapView.setOnChangedListener(this);
    innerWPsCheckbox.setOnClickListener(this);
    cameraSpinner.setOnSpinnerItemSelectedListener(this);
  }
Ejemplo n.º 2
0
    @Override
    public void updateItemView(final Context context, final Drone drone) {
      mDrone = drone;

      if (mItemView == null) return;

      final SpinnerSelfSelect modesSpinner = (SpinnerSelfSelect) mItemView;
      final int droneType = drone == null ? -1 : drone.type.getType();
      if (droneType != mLastDroneType) {
        final List<ApmModes> flightModes =
            droneType == -1 ? Collections.<ApmModes>emptyList() : ApmModes.getModeList(droneType);

        mModeAdapter.clear();
        mModeAdapter.addAll(flightModes);
        mModeAdapter.notifyDataSetChanged();

        mLastDroneType = droneType;
      }

      if (mDrone != null)
        modesSpinner.forcedSetSelection(mModeAdapter.getPosition(mDrone.state.getMode()));
    }
Ejemplo n.º 3
0
    @Override
    protected void initItemView(final Context context, View parentView, final Drone drone) {
      super.initItemView(context, parentView, drone);
      if (mItemView == null) return;

      final SpinnerSelfSelect modesSpinner = (SpinnerSelfSelect) mItemView;

      mModeAdapter = new ModeAdapter(context, R.layout.spinner_drop_down);
      modesSpinner.setAdapter(mModeAdapter);

      modesSpinner.setOnSpinnerItemSelectedListener(
          new SpinnerSelfSelect.OnSpinnerItemSelectedListener() {
            @Override
            public void onSpinnerItemSelected(Spinner parent, int position) {
              if (mDrone != null) {
                final ApmModes newMode = (ApmModes) parent.getItemAtPosition(position);
                mDrone.state.changeFlightMode(newMode);
              }
            }
          });

      updateItemView(context, drone);
    }
  @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);
  }