Search in sources :

Example 36 with PointDescription

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);
    }
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) LayoutInflater(android.view.LayoutInflater) PointDescription(net.osmand.data.PointDescription) LinearLayout(android.widget.LinearLayout)

Example 37 with PointDescription

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());
}
Also used : PointDescription(net.osmand.data.PointDescription)

Example 38 with PointDescription

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;
}
Also used : LatLon(net.osmand.data.LatLon) CheckBox(android.widget.CheckBox) PointDescription(net.osmand.data.PointDescription) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 39 with PointDescription

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);
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) AsyncTask(android.os.AsyncTask) OsmBugResult(net.osmand.plus.osmedit.OsmBugsUtil.OsmBugResult) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 40 with PointDescription

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());
        }
    };
}
Also used : PointDescription(net.osmand.data.PointDescription) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TransportStopsLayer(net.osmand.plus.views.TransportStopsLayer)

Aggregations

PointDescription (net.osmand.data.PointDescription)72 LatLon (net.osmand.data.LatLon)44 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 ArrayList (java.util.ArrayList)13 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)13 FavouritePoint (net.osmand.data.FavouritePoint)12 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)11 OsmandApplication (net.osmand.plus.OsmandApplication)10 OsmandSettings (net.osmand.plus.OsmandSettings)10 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 Amenity (net.osmand.data.Amenity)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 RoutingHelper (net.osmand.plus.routing.RoutingHelper)7 Intent (android.content.Intent)6 Paint (android.graphics.Paint)6 LinearLayout (android.widget.LinearLayout)6 Location (net.osmand.Location)6 DialogInterface (android.content.DialogInterface)5