Exemplo n.º 1
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = inflater.inflate(R.layout.fragment_base, container, false);
   ButterKnife.bind(this, view);
   try {
     setUpRecyclerView();
     initData();
   } catch (IOException | XmlPullParserException e) {
     e.printStackTrace();
   }
   return view;
 }
Exemplo n.º 2
0
  public static Parameters getParameters(
      MavLinkDrone drone, Context context, Map<String, Parameter> cachedParameters) {
    if (drone == null) return new Parameters();

    final Map<String, Parameter> incompleteParams = new HashMap<>();
    final List<Parameter> parametersList = new ArrayList<>();

    Map<String, org.droidplanner.services.android.core.parameters.Parameter> droneParameters =
        drone.getParameters().getParameters();
    if (!droneParameters.isEmpty()) {
      for (org.droidplanner.services.android.core.parameters.Parameter param :
          droneParameters.values()) {
        if (param.name != null) {
          Parameter cachedParam = cachedParameters.get(param.name);
          if (cachedParam == null) {
            cachedParam = new Parameter(param.name, param.value, param.type);
            incompleteParams.put(param.name, cachedParam);
            cachedParameters.put(param.name, cachedParam);
          } else {
            cachedParam.setValue(param.value);
            cachedParam.setType(param.type);
          }

          parametersList.add(cachedParam);
        }
      }

      final VehicleProfile profile = drone.getVehicleProfile();
      if (!incompleteParams.isEmpty() && profile != null) {
        try {
          String metadataType = profile.getParameterMetadataType();
          if (metadataType != null) {
            ParameterMetadataLoader.load(context, metadataType, incompleteParams);
          }
        } catch (IOException | XmlPullParserException e) {
          Timber.e(e, e.getMessage());
        }
      }
    }

    return new Parameters(new ArrayList<>(parametersList));
  }