use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.
the class DashOsmEditsFragment method getOsmPoints.
private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
if (l1.isEmpty()) {
int i = 0;
for (OsmPoint point : l2) {
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else if (l2.isEmpty()) {
int i = 0;
for (OsmPoint point : l1) {
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else {
dataPoints.add(l1.get(0));
dataPoints.add(l2.get(0));
if (l1.size() > 1) {
dataPoints.add(l1.get(1));
} else if (l2.size() > 1) {
dataPoints.add(l2.get(1));
}
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.
the class DashOsmEditsFragment method setupEditings.
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().getUIUtilities().getThemedIcon(R.drawable.ic_action_export));
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (point.getGroup() == OsmPoint.Group.POI) {
selectedPoint = point;
if (getMyApplication().getOsmOAuthHelper().isLogged()) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { point });
} else {
LoginBottomSheetFragment.showInstance(getActivity().getSupportFragmentManager(), DashOsmEditsFragment.this);
}
} else {
SendOsmNoteBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { 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, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
osmLayout.addView(view);
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.
the class OsmBugsLayer method createBugDialog.
private void createBugDialog(@NonNull MapActivity mapActivity, final boolean offline, String text, int titleTextId, int posButtonTextId, final Action action, final OpenStreetNote bug, OsmNotesPoint point) {
if (mapActivity.isFinishing()) {
return;
}
if (offline) {
mapActivity.getContextMenu().close();
BugBottomSheetDialog.showInstance(mapActivity.getSupportFragmentManager(), getOsmBugsUtil(bug), local, text, titleTextId, posButtonTextId, action, bug, point, getHandleBugListener(mapActivity));
} else {
OsmNotesPoint notesPoint = new OsmNotesPoint();
notesPoint.setAction(action);
notesPoint.setId(bug.getId());
notesPoint.setLatitude(bug.getLatitude());
notesPoint.setLongitude(bug.getLongitude());
SendOsmNoteBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), new OsmPoint[] { notesPoint });
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.
the class SaveOsmNoteAsyncTask method doInBackground.
@Override
protected OsmNotesPoint doInBackground(OsmNotesPoint... params) {
OsmNotesPoint mOsmNotesPoint = params[0];
Action action = mOsmNotesPoint.getAction();
plugin.getDBBug().deleteAllBugModifications(mOsmNotesPoint);
OsmBugsUtil.OsmBugResult result = mOsmbugsUtil.commit(mOsmNotesPoint, mText, action);
return result == null ? null : result.local;
}
Aggregations