use of net.osmand.data.FavouritePoint 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 favGr = helper.getGroup(entry.getKey());
MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(favGr);
if (entry.getValue().size() == favGr.points.size()) {
markersHelper.addOrEnableGroup(markersGr);
} 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, markersGr);
points.clear();
names.clear();
}
}
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavoritesTreeFragment 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);
FavouritePoint model = favouritesAdapter.getChild(groupPosition, childPosition);
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
ch.setChecked(!ch.isChecked());
if (ch.isChecked()) {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.add(model);
} else {
set = new LinkedHashSet<>();
set.add(model);
favoritesSelected.put(group.name, set);
}
} else {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.remove(model);
}
}
updateSelectionMode(actionMode);
} else {
final FavouritePoint point = favouritesAdapter.getChild(groupPosition, childPosition);
showOnMap(point);
}
return true;
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavoritesTreeFragment method generateHtmlPrint.
private StringBuilder generateHtmlPrint(List<FavoriteGroup> groups) {
StringBuilder html = new StringBuilder();
html.append("<h1>My Favorites</h1>");
for (FavoriteGroup group : groups) {
html.append("<h3>" + group.name + "</h3>");
for (FavouritePoint fp : group.points) {
String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
if (!Algorithms.isEmpty(fp.getDescription())) {
html.append(": " + fp.getDescription());
}
html.append("</p>");
}
}
return html;
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavouritesDbHelper method sortAll.
public void sortAll() {
final Collator collator = Collator.getInstance();
collator.setStrength(Collator.SECONDARY);
Collections.sort(favoriteGroups, new Comparator<FavoriteGroup>() {
@Override
public int compare(FavoriteGroup lhs, FavoriteGroup rhs) {
return collator.compare(lhs.name, rhs.name);
}
});
Comparator<FavouritePoint> favoritesComparator = getComparator();
for (FavoriteGroup g : favoriteGroups) {
Collections.sort(g.points, favoritesComparator);
}
if (cachedFavoritePoints != null) {
Collections.sort(cachedFavoritePoints, favoritesComparator);
}
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavouritesDbHelper method saveCurrentPointsIntoFile.
public void saveCurrentPointsIntoFile() {
try {
Map<String, FavouritePoint> deletedInMemory = new LinkedHashMap<String, FavouritePoint>();
loadGPXFile(getInternalFile(), deletedInMemory);
for (FavouritePoint fp : cachedFavoritePoints) {
deletedInMemory.remove(getKey(fp));
}
saveFile(cachedFavoritePoints, getInternalFile());
saveExternalFile(deletedInMemory.keySet());
backup(getBackupFile(), getExternalFile());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations