use of net.osmand.data.PointDescription 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().getIconsCache().getThemedIcon(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 }, PoiUploaderType.FRAGMENT).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, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
osmLayout.addView(view);
}
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class OsmEditsFragment method showOnMap.
private void showOnMap(OsmPoint osmPoint) {
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());
getMyApplication().getSettings().setMapLocationToShow(osmPoint.getLatitude(), osmPoint.getLongitude(), 15, new PointDescription(type, name), true, // $NON-NLS-1$
osmPoint);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class TrackPointFragment method onChildClick.
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (selectionMode) {
CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
ch.setChecked(!ch.isChecked());
if (ch.isChecked()) {
Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
if (set != null) {
set.add(item);
} else {
set = new LinkedHashSet<>();
set.add(item);
selectedItems.put(item.group.getType(), set);
}
} else {
Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
if (set != null) {
set.remove(item);
}
}
updateSelectionMode(actionMode);
} else {
final GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
if (item != null) {
if (item.group.getGpx() != null) {
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
}
final OsmandSettings settings = app.getSettings();
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, item.name), false, item.locationStart);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
return true;
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class OsmBugsLayer method asyncActionTask.
private void asyncActionTask(final OpenStreetNote bug, final OsmNotesPoint point, final String text, final Action action) {
AsyncTask<Void, Void, OsmBugResult> task = new AsyncTask<Void, Void, OsmBugResult>() {
private OsmBugsUtil osmbugsUtil;
@Override
protected OsmBugResult doInBackground(Void... params) {
if (bug != null) {
osmbugsUtil = getOsmbugsUtil(bug);
OsmNotesPoint pnt = new OsmNotesPoint();
pnt.setId(bug.getId());
pnt.setLatitude(bug.getLatitude());
pnt.setLongitude(bug.getLongitude());
return osmbugsUtil.commit(pnt, text, action);
} else if (point != null) {
osmbugsUtil = local;
return osmbugsUtil.modify(point, text);
}
return null;
}
protected void onPostExecute(OsmBugResult obj) {
if (obj != null && obj.warning == null) {
if (local == osmbugsUtil) {
Toast.makeText(activity, R.string.osm_changes_added_to_local_edits, Toast.LENGTH_LONG).show();
if (obj.local != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_OSM_BUG, obj.local.getText());
activity.getContextMenu().show(new LatLon(obj.local.getLatitude(), obj.local.getLongitude()), pd, obj.local);
}
} else {
if (action == Action.REOPEN) {
Toast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show();
} else if (action == Action.MODIFY) {
Toast.makeText(activity, R.string.osb_comment_dialog_success, Toast.LENGTH_LONG).show();
} else if (action == Action.DELETE) {
Toast.makeText(activity, R.string.osn_close_dialog_success, Toast.LENGTH_LONG).show();
} else if (action == Action.CREATE) {
Toast.makeText(activity, R.string.osn_add_dialog_success, Toast.LENGTH_LONG).show();
}
}
clearCache();
} else {
int r = R.string.osb_comment_dialog_error;
if (action == Action.REOPEN) {
r = R.string.osn_add_dialog_error;
reopenBug(bug, text);
} else if (action == Action.DELETE) {
r = R.string.osn_close_dialog_error;
closeBug(bug, text);
} else if (action == Action.CREATE) {
r = R.string.osn_add_dialog_error;
openBug(bug.getLatitude(), bug.getLongitude(), text);
} else if (action == null) {
r = R.string.osn_modify_dialog_error;
modifyBug(point);
} else {
commentBug(bug, text);
}
Toast.makeText(activity, activity.getResources().getString(r) + "\n" + obj, Toast.LENGTH_LONG).show();
}
}
};
executeTaskInBackground(task);
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MenuBuilder method createTransportRoutesViewClickListener.
private View.OnClickListener createTransportRoutesViewClickListener(final TransportStopRoute r) {
return new View.OnClickListener() {
@Override
public void onClick(View arg0) {
MapContextMenu mm = getMapActivity().getContextMenu();
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, r.getDescription(getMapActivity().getMyApplication(), false));
mm.show(latLon, pd, r);
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(r);
int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
}
};
}
Aggregations