use of net.osmand.plus.mapmarkers.MapMarkersHelper in project Osmand by osmandapp.
the class ExternalApiHelper method processApiRequest.
public Intent processApiRequest(Intent intent) {
Intent result = new Intent();
OsmandApplication app = (OsmandApplication) mapActivity.getApplication();
try {
Uri uri = intent.getData();
String cmd = uri.getHost().toLowerCase();
if (API_CMD_SHOW_GPX.equals(cmd) || API_CMD_NAVIGATE_GPX.equals(cmd)) {
boolean navigate = API_CMD_NAVIGATE_GPX.equals(cmd);
String path = uri.getQueryParameter(PARAM_PATH);
GPXFile gpx = null;
if (path != null) {
File f = new File(path);
if (f.exists()) {
gpx = GPXUtilities.loadGPXFile(f);
}
} else if (intent.getStringExtra(PARAM_DATA) != null) {
String gpxStr = intent.getStringExtra(PARAM_DATA);
if (!Algorithms.isEmpty(gpxStr)) {
gpx = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxStr.getBytes()));
}
} else if (uri.getBooleanQueryParameter(PARAM_URI, false)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
LOG.debug("uriString=" + intent.getClipData().getItemAt(0).getUri());
Uri gpxUri = intent.getClipData().getItemAt(0).getUri();
ParcelFileDescriptor gpxParcelDescriptor = mapActivity.getContentResolver().openFileDescriptor(gpxUri, "r");
if (gpxParcelDescriptor != null) {
FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
gpx = GPXUtilities.loadGPXFile(new FileInputStream(fileDescriptor));
} else {
finish = true;
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
}
} else {
finish = true;
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
}
} else {
finish = true;
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
}
if (gpx != null) {
if (navigate) {
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false);
saveAndNavigateGpx(mapActivity, gpx, force, locationPermission);
} else {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
}
resultCode = Activity.RESULT_OK;
} else {
finish = true;
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
}
} else if (API_CMD_NAVIGATE.equals(cmd)) {
String profileStr = uri.getQueryParameter(PARAM_PROFILE);
final ApplicationMode profile = findNavigationProfile(app, profileStr);
if (profile == null) {
resultCode = RESULT_CODE_ERROR_INVALID_PROFILE;
} else {
String startName = uri.getQueryParameter(PARAM_START_NAME);
if (Algorithms.isEmpty(startName)) {
startName = "";
}
String destName = uri.getQueryParameter(PARAM_DEST_NAME);
if (Algorithms.isEmpty(destName)) {
destName = "";
}
final LatLon start;
final PointDescription startDesc;
String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
String startLonStr = uri.getQueryParameter(PARAM_START_LON);
if (!Algorithms.isEmpty(startLatStr) && !Algorithms.isEmpty(startLonStr)) {
double lat = Double.parseDouble(startLatStr);
double lon = Double.parseDouble(startLonStr);
start = new LatLon(lat, lon);
startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
} else {
start = null;
startDesc = null;
}
String destLatStr = uri.getQueryParameter(PARAM_DEST_LAT);
String destLonStr = uri.getQueryParameter(PARAM_DEST_LON);
final LatLon dest;
if (!Algorithms.isEmpty(destLatStr) && !Algorithms.isEmpty(destLonStr)) {
double destLat = Double.parseDouble(destLatStr);
double destLon = Double.parseDouble(destLonStr);
dest = new LatLon(destLat, destLon);
} else {
dest = null;
}
final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName);
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
final boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false);
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && !force) {
mapActivity.getMapActions().stopNavigationActionConfirm(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) {
startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission);
}
}
});
} else {
startNavigation(mapActivity, start, startDesc, dest, destDesc, profile, locationPermission);
}
}
} else if (API_CMD_NAVIGATE_SEARCH.equals(cmd)) {
String profileStr = uri.getQueryParameter(PARAM_PROFILE);
final ApplicationMode profile = findNavigationProfile(app, profileStr);
final boolean showSearchResults = uri.getBooleanQueryParameter(PARAM_SHOW_SEARCH_RESULTS, false);
final String searchQuery = uri.getQueryParameter(PARAM_DEST_SEARCH_QUERY);
if (Algorithms.isEmpty(searchQuery)) {
resultCode = RESULT_CODE_ERROR_EMPTY_SEARCH_QUERY;
} else if (profile == null) {
resultCode = RESULT_CODE_ERROR_INVALID_PROFILE;
} else {
String startName = uri.getQueryParameter(PARAM_START_NAME);
if (Algorithms.isEmpty(startName)) {
startName = "";
}
final LatLon start;
final PointDescription startDesc;
String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
String startLonStr = uri.getQueryParameter(PARAM_START_LON);
if (!Algorithms.isEmpty(startLatStr) && !Algorithms.isEmpty(startLonStr)) {
double lat = Double.parseDouble(startLatStr);
double lon = Double.parseDouble(startLonStr);
start = new LatLon(lat, lon);
startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
} else {
start = null;
startDesc = null;
}
final LatLon searchLocation;
String searchLatStr = uri.getQueryParameter(PARAM_SEARCH_LAT);
String searchLonStr = uri.getQueryParameter(PARAM_SEARCH_LON);
if (!Algorithms.isEmpty(searchLatStr) && !Algorithms.isEmpty(searchLonStr)) {
double lat = Double.parseDouble(searchLatStr);
double lon = Double.parseDouble(searchLonStr);
searchLocation = new LatLon(lat, lon);
} else {
searchLocation = null;
}
if (searchLocation == null) {
resultCode = RESULT_CODE_ERROR_SEARCH_LOCATION_UNDEFINED;
} else {
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
final boolean locationPermission = uri.getBooleanQueryParameter(PARAM_LOCATION_PERMISSION, false);
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && !force) {
mapActivity.getMapActions().stopNavigationActionConfirm(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) {
searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults, locationPermission);
}
}
});
} else {
searchAndNavigate(mapActivity, searchLocation, start, startDesc, profile, searchQuery, showSearchResults, locationPermission);
}
resultCode = Activity.RESULT_OK;
}
}
} else if (API_CMD_PAUSE_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isRouteCalculated() && !routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(true);
routingHelper.setFollowingMode(false);
routingHelper.setPauseNavigation(true);
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_RESUME_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isRouteCalculated() && routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false);
routingHelper.setFollowingMode(true);
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_STOP_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isPauseNavigation() || routingHelper.isFollowingMode()) {
mapActivity.getMapLayers().getMapControlsLayer().stopNavigationWithoutConfirm();
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_MUTE_NAVIGATION.equals(cmd)) {
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
resultCode = Activity.RESULT_OK;
} else if (API_CMD_UNMUTE_NAVIGATION.equals(cmd)) {
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
resultCode = Activity.RESULT_OK;
} else if (API_CMD_RECORD_AUDIO.equals(cmd) || API_CMD_RECORD_VIDEO.equals(cmd) || API_CMD_RECORD_PHOTO.equals(cmd) || API_CMD_STOP_AV_REC.equals(cmd)) {
AudioVideoNotesPlugin plugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
finish = true;
} else {
if (API_CMD_STOP_AV_REC.equals(cmd)) {
plugin.stopRecording(mapActivity, false);
} else {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
if (API_CMD_RECORD_AUDIO.equals(cmd)) {
plugin.recordAudio(lat, lon, mapActivity);
} else if (API_CMD_RECORD_VIDEO.equals(cmd)) {
plugin.recordVideo(lat, lon, mapActivity, false);
} else if (API_CMD_RECORD_PHOTO.equals(cmd)) {
plugin.takePhoto(lat, lon, mapActivity, true, false);
}
}
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_GET_INFO.equals(cmd)) {
Location location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
if (location != null) {
result.putExtra(PARAM_LAT, location.getLatitude());
result.putExtra(PARAM_LON, location.getLongitude());
}
LatLon mapLocation = mapActivity.getMapLocation();
if (location != null) {
result.putExtra(PARAM_MAP_LAT, mapLocation.getLatitude());
result.putExtra(PARAM_MAP_LON, mapLocation.getLongitude());
}
RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isRouteCalculated()) {
LatLon finalLocation = routingHelper.getFinalLocation();
result.putExtra(PARAM_DESTINATION_LAT, finalLocation.getLatitude());
result.putExtra(PARAM_DESTINATION_LON, finalLocation.getLongitude());
int time = routingHelper.getLeftTime();
long eta = time + System.currentTimeMillis() / 1000;
result.putExtra(PARAM_ETA, eta);
result.putExtra(PARAM_TIME_LEFT, time);
result.putExtra(PARAM_DISTANCE_LEFT, routingHelper.getLeftDistance());
result.putExtras(getRouteDirectionsInfo(app));
}
result.putExtra(PARAM_VERSION, VERSION_CODE);
finish = true;
resultCode = Activity.RESULT_OK;
} else if (API_CMD_ADD_FAVORITE.equals(cmd)) {
String name = uri.getQueryParameter(PARAM_NAME);
String desc = uri.getQueryParameter(PARAM_DESC);
String category = uri.getQueryParameter(PARAM_CATEGORY);
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
String colorTag = uri.getQueryParameter(PARAM_COLOR);
boolean visible = uri.getBooleanQueryParameter(PARAM_VISIBLE, true);
if (name == null) {
name = "";
}
if (desc == null) {
desc = "";
}
if (category == null) {
category = "";
}
int color = 0;
if (!Algorithms.isEmpty(colorTag)) {
color = ColorDialogs.getColorByTag(colorTag);
if (color == 0) {
LOG.error("Wrong color tag: " + colorTag);
}
}
FavouritePoint fav = new FavouritePoint(lat, lon, name, category);
fav.setDescription(desc);
fav.setColor(color);
fav.setVisible(visible);
FavouritesHelper helper = app.getFavoritesHelper();
helper.addFavourite(fav);
showOnMap(lat, lon, fav, mapActivity.getMapLayers().getFavouritesLayer().getObjectName(fav));
resultCode = Activity.RESULT_OK;
} else if (API_CMD_ADD_MAP_MARKER.equals(cmd)) {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
String name = uri.getQueryParameter(PARAM_NAME);
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, name != null ? name : "");
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(lat, lon), pd, null);
MapMarker marker = markersHelper.getFirstMapMarker();
if (marker != null) {
showOnMap(lat, lon, marker, mapActivity.getMapLayers().getMapMarkersLayer().getObjectName(marker));
}
resultCode = Activity.RESULT_OK;
} else if (API_CMD_SHOW_LOCATION.equals(cmd)) {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_LON));
showOnMap(lat, lon, null, null);
resultCode = Activity.RESULT_OK;
} else if (API_CMD_START_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
finish = true;
} else {
plugin.startGPXMonitoring(null);
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
resultCode = Activity.RESULT_OK;
} else if (API_CMD_STOP_GPX_REC.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
finish = true;
} else {
plugin.stopRecording();
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
resultCode = Activity.RESULT_OK;
} else if (API_CMD_SAVE_GPX.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
finish = true;
} else {
plugin.saveCurrentTrack();
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
resultCode = Activity.RESULT_OK;
} else if (API_CMD_CLEAR_GPX.equals(cmd)) {
OsmandMonitoringPlugin plugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (plugin == null) {
resultCode = RESULT_CODE_ERROR_PLUGIN_INACTIVE;
finish = true;
} else {
app.getSavingTrackHelper().clearRecordedData(true);
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
resultCode = Activity.RESULT_OK;
} else if (API_CMD_EXECUTE_QUICK_ACTION.equals(cmd)) {
int actionNumber = Integer.parseInt(uri.getQueryParameter(PARAM_QUICK_ACTION_NUMBER));
List<QuickAction> actionsList = app.getQuickActionRegistry().getFilteredQuickActions();
if (actionNumber >= 0 && actionNumber < actionsList.size()) {
QuickActionRegistry.produceAction(actionsList.get(actionNumber)).execute(mapActivity);
resultCode = Activity.RESULT_OK;
} else {
resultCode = RESULT_CODE_ERROR_QUICK_ACTION_NOT_FOUND;
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
} else if (API_CMD_GET_QUICK_ACTION_INFO.equals(cmd)) {
int actionNumber = Integer.parseInt(uri.getQueryParameter(PARAM_QUICK_ACTION_NUMBER));
List<QuickAction> actionsList = app.getQuickActionRegistry().getFilteredQuickActions();
if (actionNumber >= 0 && actionNumber < actionsList.size()) {
QuickAction action = actionsList.get(actionNumber);
Gson gson = new Gson();
Type type = new TypeToken<HashMap<String, String>>() {
}.getType();
result.putExtra(PARAM_QUICK_ACTION_NAME, action.getName(app));
result.putExtra(PARAM_QUICK_ACTION_TYPE, action.getActionType().getStringId());
result.putExtra(PARAM_QUICK_ACTION_PARAMS, gson.toJson(action.getParams(), type));
result.putExtra(PARAM_VERSION, VERSION_CODE);
resultCode = Activity.RESULT_OK;
} else {
resultCode = RESULT_CODE_ERROR_QUICK_ACTION_NOT_FOUND;
}
if (uri.getBooleanQueryParameter(PARAM_CLOSE_AFTER_COMMAND, true)) {
finish = true;
}
} else if (API_CMD_SUBSCRIBE_VOICE_NOTIFICATIONS.equals(cmd)) {
// not implemented yet
resultCode = RESULT_CODE_ERROR_NOT_IMPLEMENTED;
}
} catch (Exception e) {
LOG.error("Error processApiRequest:", e);
resultCode = RESULT_CODE_ERROR_UNKNOWN;
}
return result;
}
use of net.osmand.plus.mapmarkers.MapMarkersHelper in project Osmand by osmandapp.
the class MapMarkersGroupsAdapter method createDisplayGroups.
private void createDisplayGroups() {
items = new ArrayList<>();
MapMarkersHelper helper = app.getMapMarkersHelper();
helper.updateGroups();
List<MapMarkersGroup> groups = new ArrayList<>(helper.getVisibleMapMarkersGroups());
groups.addAll(helper.getGroupsForDisplayedGpx());
groups.addAll(helper.getGroupsForSavedArticlesTravelBook());
// evaluate time constants
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
long currentTimeMillis = System.currentTimeMillis();
Calendar currentDateCalendar = Calendar.getInstance();
currentDateCalendar.setTimeInMillis(currentTimeMillis);
// evaluate today, yesterday, last 7 days
String today = dateFormat.format(currentDateCalendar.getTime());
currentDateCalendar.add(Calendar.DAY_OF_YEAR, -1);
String yesterday = dateFormat.format(currentDateCalendar.getTime());
currentDateCalendar.set(Calendar.HOUR_OF_DAY, 0);
currentDateCalendar.set(Calendar.MINUTE, 0);
currentDateCalendar.add(Calendar.DAY_OF_YEAR, -6);
long last7Days = currentDateCalendar.getTimeInMillis();
// evaluate this year & last 3 months
currentDateCalendar.setTimeInMillis(currentTimeMillis);
String thisYear = dateFormat.format(currentDateCalendar.getTime()).substring(0, 5);
currentDateCalendar.add(Calendar.MONTH, -1);
String monthMinus1 = dateFormat.format(currentDateCalendar.getTime()).substring(0, 8);
currentDateCalendar.add(Calendar.MONTH, -1);
String monthMinus2 = dateFormat.format(currentDateCalendar.getTime()).substring(0, 8);
currentDateCalendar.add(Calendar.MONTH, -1);
String monthMinus3 = dateFormat.format(currentDateCalendar.getTime()).substring(0, 8);
Calendar markerCalendar = Calendar.getInstance();
for (int i = 0; i < groups.size(); i++) {
MapMarkersGroup group = groups.get(i);
String markerGroupName = group.getName();
if (markerGroupName == null) {
int previousGroupDateId = 0;
List<MapMarker> groupMarkers = group.getActiveMarkers();
for (int j = 0; j < groupMarkers.size(); j++) {
MapMarker marker = groupMarkers.get(j);
String markerDate = dateFormat.format(new Date(marker.creationDate));
int currentGroupDateId;
MarkerGroupItem currentGroupItem = null;
if (marker.creationDate >= currentTimeMillis || (today.equals(markerDate))) {
currentGroupDateId = -1;
currentGroupItem = MarkerGroupItem.TODAY_HEADER;
} else if (yesterday.equals(markerDate)) {
currentGroupDateId = -2;
currentGroupItem = MarkerGroupItem.YESTERDAY_HEADER;
} else if (marker.creationDate >= last7Days) {
currentGroupDateId = -3;
currentGroupItem = MarkerGroupItem.LAST_SEVEN_DAYS_HEADER;
} else if (markerDate.startsWith(monthMinus1)) {
currentGroupDateId = -5;
} else if (markerDate.startsWith(monthMinus2)) {
currentGroupDateId = -6;
} else if (markerDate.startsWith(monthMinus3)) {
currentGroupDateId = -7;
} else if (markerDate.startsWith(thisYear)) {
currentGroupItem = MarkerGroupItem.THIS_YEAR_HEADER;
currentGroupDateId = -4;
} else {
markerCalendar.setTimeInMillis(marker.creationDate);
currentGroupDateId = markerCalendar.get(Calendar.YEAR);
}
if (previousGroupDateId != currentGroupDateId) {
if (currentGroupItem != null) {
items.add(currentGroupItem);
} else if (currentGroupDateId < 0) {
SimpleDateFormat monthdateFormat = new SimpleDateFormat("LLLL", Locale.getDefault());
String monthStr = monthdateFormat.format(new Date(marker.creationDate));
if (monthStr.length() > 1) {
monthStr = Algorithms.capitalizeFirstLetter(monthStr);
}
items.add(new MarkerGroupItem(monthStr));
} else {
items.add(new MarkerGroupItem(currentGroupDateId + ""));
}
previousGroupDateId = currentGroupDateId;
}
items.add(marker);
}
} else {
items.add(new GroupHeader(group));
if (!group.isDisabled()) {
if (group.getWptCategories() != null && !group.getWptCategories().isEmpty()) {
CategoriesSubHeader categoriesSubHeader = new CategoriesSubHeader(group);
items.add(categoriesSubHeader);
}
TravelHelper travelHelper = mapActivity.getMyApplication().getTravelHelper();
if (travelHelper.isAnyTravelBookPresent()) {
List<TravelArticle> savedArticles = travelHelper.getBookmarksHelper().getSavedArticles();
for (TravelArticle art : savedArticles) {
String gpxName = travelHelper.getGPXName(art);
File path = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
if (path.getAbsolutePath().equals(group.getGpxPath(app))) {
group.setWikivoyageArticle(art);
}
}
}
}
if (Algorithms.isEmpty(group.getWptCategories())) {
helper.updateGroupWptCategories(group, getGpxFile(group.getGpxPath(app)).getPointsByCategories().keySet());
}
populateAdapterWithGroupMarkers(group, getItemCount());
}
}
}
use of net.osmand.plus.mapmarkers.MapMarkersHelper in project Osmand by osmandapp.
the class AddPointBottomSheetDialog method createMarkersScrollItem.
private void createMarkersScrollItem() {
final OsmandApplication app = getMyApplication();
if (app != null) {
List<Object> items = new ArrayList<>();
MarkersItemsAdapter adapter = new MarkersItemsAdapter(app, items);
adapter.setItemClickListener(getAdapterOnClickListener(items));
MapMarkersHelper helper = app.getMapMarkersHelper();
items.add(MARKERS);
items.addAll(helper.getMapMarkers());
BaseBottomSheetItem scrollItem = new HorizontalRecyclerBottomSheetItem.Builder().setAdapter(adapter).setLayoutId(R.layout.bottom_sheet_item_recyclerview).create();
this.items.add(scrollItem);
}
}
use of net.osmand.plus.mapmarkers.MapMarkersHelper in project Osmand by osmandapp.
the class FavouritesHelper method addToMarkers.
private void addToMarkers(FavoriteGroup favGroup) {
MapMarkersHelper helper = app.getMapMarkersHelper();
helper.addOrEnableGroup(favGroup);
}
use of net.osmand.plus.mapmarkers.MapMarkersHelper in project Osmand by osmandapp.
the class FavoritesTreeFragment method selectMapMarkersImpl.
private void selectMapMarkersImpl() {
if (getSelectedFavoritesCount() > 0) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
List<LatLon> points = new ArrayList<>();
List<PointDescription> names = new ArrayList<>();
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
FavoriteGroup group = helper.getGroup(entry.getKey());
if (group != null && entry.getValue().size() == group.getPoints().size()) {
markersHelper.addOrEnableGroup(group);
} else {
for (FavouritePoint fp : entry.getValue()) {
points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
}
markersHelper.addMapMarkers(points, names, null);
points.clear();
names.clear();
}
}
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
Aggregations