use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.
the class OsmEditsFragment method showOnMap.
private void showOnMap(OsmPoint osmPoint, int itemPosition) {
selectedItemPosition = itemPosition;
boolean isOsmPoint = osmPoint instanceof OpenstreetmapPoint;
String type = osmPoint.getGroup() == Group.POI ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG;
String name = (isOsmPoint ? ((OpenstreetmapPoint) osmPoint).getName() : ((OsmNotesPoint) osmPoint).getText());
FavoritesActivity.showOnMap(requireActivity(), this, osmPoint.getLatitude(), osmPoint.getLongitude(), 15, new PointDescription(type, name), true, osmPoint);
}
use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.
the class OsmEditsFragment method fetchData.
private void fetchData() {
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
osmEdits = new ArrayList<>();
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
osmEdits.addAll(l1);
osmEdits.addAll(l2);
ListView listView = getListView();
listView.setDivider(null);
listView.setEmptyView(emptyView);
if (osmEdits.size() > 0 && footerView == null && portrait) {
footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
listView.addFooterView(footerView);
}
List<Object> items = createItemsList();
listAdapter = new OsmEditsAdapter(getMyApplication(), items);
listAdapter.setSelectedOsmEdits(osmEditsSelected);
listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {
@Override
public void onHeaderCheckboxClick(boolean checked) {
if (checked) {
selectAll();
} else {
deselectAll();
}
updateSelectionTitle(actionMode);
}
@Override
public void onItemSelect(OsmPoint point, boolean checked) {
if (checked) {
osmEditsSelected.add(point);
} else {
osmEditsSelected.remove(point);
}
updateSelectionMode(actionMode);
}
@Override
public void onItemShowMap(OsmPoint point, int position) {
showOnMap(point, position);
}
@Override
public void onOptionsClick(OsmPoint note) {
openPopUpMenu(note);
}
});
listAdapter.setPortrait(portrait);
listView.setAdapter(listAdapter);
}
use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.
the class SendPoiBottomSheetFragment method onRightBottomButtonClick.
@Override
protected void onRightBottomButtonClick() {
ProgressDialogPoiUploader progressDialogPoiUploader = null;
Activity activity = getActivity();
if (activity instanceof MapActivity) {
progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity);
} else if (getParentFragment() instanceof ProgressDialogPoiUploader) {
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
}
if (progressDialogPoiUploader != null) {
String comment = messageEditText.getText().toString();
if (comment.length() > 0) {
for (OsmPoint osmPoint : poi) {
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
((OpenstreetmapPoint) osmPoint).setComment(comment);
break;
}
}
}
progressDialogPoiUploader.showProgressDialog(poi, closeChangeSet.isChecked(), false);
}
dismiss();
}
use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.
the class UploadOpenstreetmapPointAsyncTask method doInBackground.
@Override
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
TrafficStats.setThreadStatsTag(THREAD_ID);
Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
boolean uploaded = false;
for (OsmPoint point : points) {
if (interruptUploading) {
break;
}
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
EntityInfo entityInfo = null;
p.trimChangedTagNamesValues();
if (OsmPoint.Action.CREATE != p.getAction()) {
entityInfo = remotepoi.loadEntity(p.getEntity());
}
Entity n = remotepoi.commitEntityImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false, null);
if (n != null) {
uploaded = true;
plugin.getDBPOI().deletePOI(p);
publishProgress(p);
}
loadErrorsMap.put(point, n != null ? null : "Unknown problem");
} else if (point.getGroup() == OsmPoint.Group.BUG) {
OsmNotesPoint p = (OsmNotesPoint) point;
String errorMessage = remotebug.commit(p, p.getText(), p.getAction(), loadAnonymous).warning;
if (errorMessage == null) {
plugin.getDBBug().deleteAllBugModifications(p);
publishProgress(p);
}
loadErrorsMap.put(point, errorMessage);
}
}
if (uploaded && closeChangeSet) {
remotepoi.closeChangeSet();
}
return loadErrorsMap;
}
use of net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint in project Osmand by osmandapp.
the class OpenstreetmapLocalUtil method commitEntityImpl.
@Override
public Entity commitEntityImpl(Action action, Entity entity, EntityInfo info, String comment, boolean closeChangeSet, Set<String> changedTags) {
Entity newEntity = entity;
if (entity.getId() == -1) {
if (entity instanceof Node) {
newEntity = new Node((Node) entity, Math.min(-2, plugin.getDBPOI().getMinID() - 1));
} else if (entity instanceof Way) {
newEntity = new Way(Math.min(-2, plugin.getDBPOI().getMinID() - 1), ((Way) entity).getNodeIds(), entity.getLatitude(), entity.getLongitude());
} else {
return null;
}
}
OpenstreetmapPoint p = new OpenstreetmapPoint();
newEntity.setChangedTags(changedTags);
p.setEntity(newEntity);
p.setAction(action);
p.setComment(comment);
if (p.getAction() == OsmPoint.Action.DELETE && newEntity.getId() < 0) {
// if it is our local poi
plugin.getDBPOI().deletePOI(p);
} else {
plugin.getDBPOI().addOpenstreetmap(p);
}
for (OnNodeCommittedListener listener : listeners) {
listener.onNoteCommitted();
}
return newEntity;
}
Aggregations