Beispiel #1
0
  private void setupEditings() {
    View mainView = getView();
    assert mainView != null;
    if (plugin == null) {
      mainView.setVisibility(View.GONE);
      return;
    }

    ArrayList<OsmPoint> dataPoints = new ArrayList<>();
    getOsmPoints(dataPoints);
    if (dataPoints.size() == 0) {
      mainView.setVisibility(View.GONE);
      return;
    } else {
      mainView.setVisibility(View.VISIBLE);
      DashboardOnMap.handleNumberOfRows(
          dataPoints, getMyApplication().getSettings(), ROW_NUMBER_TAG);
    }

    LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items);
    osmLayout.removeAllViews();

    for (final OsmPoint point : dataPoints) {
      LayoutInflater inflater = getActivity().getLayoutInflater();
      View view = inflater.inflate(R.layout.note, null, false);

      OsmEditsFragment.getOsmEditView(view, point, getMyApplication());
      ImageButton send = (ImageButton) view.findViewById(R.id.play);
      send.setImageDrawable(
          getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_export));
      send.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (point.getGroup() == OsmPoint.Group.POI) {
                SendPoiDialogFragment.createInstance(new OsmPoint[] {point})
                    .show(getChildFragmentManager(), "SendPoiDialogFragment");
              } else {
                uploadItem(point);
              }
            }
          });
      view.findViewById(R.id.options).setVisibility(View.GONE);
      view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
      view.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              boolean poi = point.getGroup() == OsmPoint.Group.POI;
              String name =
                  poi ? ((OpenstreetmapPoint) point).getName() : ((OsmNotesPoint) point).getText();
              getMyApplication()
                  .getSettings()
                  .setMapLocationToShow(
                      point.getLatitude(),
                      point.getLongitude(),
                      15,
                      new PointDescription(
                          poi
                              ? PointDescription.POINT_TYPE_POI
                              : PointDescription.POINT_TYPE_OSM_BUG,
                          name),
                      true,
                      point); //$NON-NLS-1$
              MapActivity.launchMapActivityMoveToTop(getActivity());
            }
          });
      osmLayout.addView(view);
    }
  }