private void writeContent(XmlSerializer sz, OsmPoint[] points, Action a)
     throws IllegalArgumentException, IllegalStateException, IOException {
   for (OsmPoint point : points) {
     if (point.getGroup() == OsmPoint.Group.POI) {
       OpenstreetmapPoint p = (OpenstreetmapPoint) point;
       if (p.getAction() == a) {
         sz.startTag("", "node");
         sz.attribute("", "lat", p.getLatitude() + "");
         sz.attribute("", "lon", p.getLongitude() + "");
         sz.attribute("", "id", p.getId() + "");
         for (String tag : p.getEntity().getTagKeySet()) {
           String val = p.getEntity().getTag(tag);
           sz.startTag("", "tag");
           sz.attribute("", "k", tag);
           sz.attribute("", "v", val);
           sz.endTag("", "tag");
         }
         sz.endTag("", "node");
       }
     } else if (point.getGroup() == OsmPoint.Group.BUG) {
       OsmNotesPoint p = (OsmNotesPoint) point;
       if (p.getAction() == a) {
         sz.startTag("", "note");
         sz.attribute("", "lat", p.getLatitude() + "");
         sz.attribute("", "lon", p.getLongitude() + "");
         sz.attribute("", "id", p.getId() + "");
         sz.startTag("", "comment");
         sz.attribute("", "text", p.getText() + "");
         sz.endTag("", "comment");
         sz.endTag("", "note");
       }
     }
   }
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View v = convertView;
      final OsmPoint child = getItem(position);
      if (v == null) {
        LayoutInflater inflater = getLayoutInflater();
        v = inflater.inflate(net.osmand.plus.R.layout.local_openstreetmap_list_item, parent, false);
      }
      TextView viewName = ((TextView) v.findViewById(R.id.local_openstreetmap_name));
      String idPrefix =
          (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId();
      if (child.getGroup() == OsmPoint.Group.POI)
        viewName.setText(
            idPrefix
                + " ("
                + ((OpenstreetmapPoint) child).getSubtype()
                + ") "
                + ((OpenstreetmapPoint) child).getName());
      else if (child.getGroup() == OsmPoint.Group.BUG)
        viewName.setText(
            idPrefix
                + " ("
                + ((OsmNotesPoint) child).getAuthor()
                + ") "
                + ((OsmNotesPoint) child).getText());
      if (child.getAction() == OsmPoint.Action.CREATE) {
        viewName.setTextColor(getResources().getColor(R.color.color_ok));
      } else if (child.getAction() == OsmPoint.Action.MODIFY) {
        viewName.setTextColor(getResources().getColor(R.color.color_update));
      } else if (child.getAction() == OsmPoint.Action.DELETE) {
        viewName.setTextColor(getResources().getColor(R.color.color_warning));
      }

      return v;
    }
    @Override
    protected Integer doInBackground(OsmPoint... points) {
      int uploaded = 0;

      for (OsmPoint point : points) {
        if (interruptUploading) break;

        if (point.getGroup() == OsmPoint.Group.POI) {
          OpenstreetmapPoint p = (OpenstreetmapPoint) point;
          EntityInfo entityInfo = null;
          if (OsmPoint.Action.CREATE != p.getAction()) {
            entityInfo = remotepoi.loadNode(p.getEntity());
          }
          Node n =
              remotepoi.commitNodeImpl(
                  p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
          if (n != null) {
            dbpoi.deletePOI(p);
            publishProgress(p);
            uploaded++;
          }
        } else if (point.getGroup() == OsmPoint.Group.BUG) {
          OsmNotesPoint p = (OsmNotesPoint) point;
          boolean success = false;
          if (p.getAction() == OsmPoint.Action.CREATE) {
            success =
                remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText()) == null;
          } else if (p.getAction() == OsmPoint.Action.MODIFY) {
            success = remotebug.addingComment(p.getId(), p.getText()) == null;
          } else if (p.getAction() == OsmPoint.Action.DELETE) {
            success = remotebug.closingBug(p.getId(), p.getText()) == null;
          }
          if (success) {
            dbbug.deleteAllBugModifications(p);
            uploaded++;
            publishProgress(p);
          }
        }
      }

      return Integer.valueOf(uploaded);
    }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    int pos = ((android.widget.AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    int itemId = item.getItemId();
    if (itemId == R.id.showmod) {
      OsmandSettings settings = getMyApplication().getSettings();
      OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
      settings.setMapLocationToShow(
          info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom());
      MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this);
      return true;
    } else if (itemId == R.id.deletemod) {
      OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
      if (info.getGroup() == OsmPoint.Group.POI) {
        dbpoi.deletePOI((OpenstreetmapPoint) info);
      } else if (info.getGroup() == OsmPoint.Group.BUG) {
        dbbug.deleteAllBugModifications((OsmNotesPoint) info);
      }
      listAdapter.delete(info);
      return true;
    } else if (itemId == R.id.uploadmods) {
      toUpload = new OsmPoint[] {listAdapter.getItem(pos)};
      showDialog(DIALOG_PROGRESS_UPLOAD);
      return true;
    }

    return super.onContextItemSelected(item);
  }