Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-04-08 08:32:46 +02:00
commit aff57c34f7
10 changed files with 55 additions and 164 deletions

View file

@ -9,15 +9,12 @@ import net.osmand.data.PointDescription;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class MapMarkersHelper {
public static final int MAP_MARKERS_COLORS_COUNT = 7;
private List<MapMarker> mapMarkers = new ArrayList<>();
private List<MapMarker> sortedMapMarkers = new ArrayList<>();
private List<MapMarker> mapMarkersHistory = new ArrayList<>();
private OsmandSettings settings;
private List<MapMarkerChangedListener> listeners = new ArrayList<>();
@ -34,18 +31,16 @@ public class MapMarkersHelper {
public LatLon point;
private PointDescription pointDescription;
public int colorIndex;
public int pos;
public int index;
public boolean history;
public boolean selected;
public int dist;
public MapMarker(LatLon point, PointDescription name, int colorIndex, int pos,
public MapMarker(LatLon point, PointDescription name, int colorIndex,
boolean selected, int index) {
this.point = point;
this.pointDescription = name;
this.colorIndex = colorIndex;
this.pos = pos;
this.selected = selected;
this.index = index;
}
@ -89,7 +84,6 @@ public class MapMarkersHelper {
MapMarker mapMarker = (MapMarker) o;
if (colorIndex != mapMarker.colorIndex) return false;
if (pos != mapMarker.pos) return false;
return point.equals(mapMarker.point);
}
@ -98,7 +92,6 @@ public class MapMarkersHelper {
public int hashCode() {
int result = point.hashCode();
result = 31 * result + colorIndex;
result = 31 * result + pos;
return result;
}
}
@ -134,32 +127,23 @@ public class MapMarkersHelper {
List<LatLon> ips = settings.getMapMarkersPoints();
List<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
List<Integer> colors = settings.getMapMarkersColors(ips.size());
List<Integer> positions = settings.getMapMarkersPositions(ips.size());
List<Boolean> selections = settings.getMapMarkersSelections(ips.size());
int colorIndex = 0;
int pos = 0;
for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
colorIndex = colors.get(i);
}
if (positions.size() > i) {
pos = positions.get(i);
} else {
pos++;
}
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
pos, selections.get(i), i);
selections.get(i), i);
mapMarkers.add(mapMarker);
}
updateSortedArray();
ips = settings.getMapMarkersHistoryPoints();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size());
for (int i = 0; i < ips.size(); i++) {
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, 0, false, i);
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, false, i);
mapMarker.history = true;
mapMarkersHistory.add(mapMarker);
}
@ -169,25 +153,6 @@ public class MapMarkersHelper {
}
}
private void updateSortedArray() {
sortedMapMarkers.clear();
sortedMapMarkers.addAll(mapMarkers);
Collections.sort(sortedMapMarkers, new Comparator<MapMarker>() {
@Override
public int compare(MapMarker lhs, MapMarker rhs) {
return lhs.pos < rhs.pos ? -1 : (lhs.pos == rhs.pos ? 0 : 1);
}
});
}
public void normalizePositions() {
for (int i = 0; i < sortedMapMarkers.size(); i++) {
MapMarker marker = sortedMapMarkers.get(i);
marker.pos = i;
}
saveMapMarkers(mapMarkers, null);
}
private void lookupAddress(final MapMarker mapMarker, final boolean history) {
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
cancelPointAddressRequests(mapMarker.point);
@ -204,7 +169,7 @@ public class MapMarkersHelper {
mapMarker.pointDescription, mapMarker.colorIndex);
} else {
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.pos, mapMarker.selected);
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.selected);
}
updateMarker(mapMarker);
}
@ -221,11 +186,10 @@ public class MapMarkersHelper {
for (MapMarker marker : mapMarkers) {
marker.index = ind++;
}
updateSortedArray();
refresh();
}
public List<MapMarker> getActiveMapMarkers() {
public List<MapMarker> getMapMarkers() {
return mapMarkers;
}
@ -237,10 +201,6 @@ public class MapMarkersHelper {
}
}
public List<MapMarker> getSortedMapMarkers() {
return sortedMapMarkers;
}
public List<MapMarker> getMapMarkersHistory() {
return mapMarkersHistory;
}
@ -342,8 +302,8 @@ public class MapMarkersHelper {
pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
}
if (colorIndex == -1) {
if (sortedMapMarkers.size() > 0) {
colorIndex = (sortedMapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
if (mapMarkers.size() > 0) {
colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
} else {
colorIndex = 0;
}
@ -369,14 +329,13 @@ public class MapMarkersHelper {
settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions,
selections, indexes);
readFromSettings();
normalizePositions();
}
}
public void updateMapMarker(MapMarker marker, boolean refresh) {
if (marker != null) {
settings.updateMapMarker(marker.getLatitude(), marker.getLongitude(),
marker.pointDescription, marker.colorIndex, marker.pos, marker.selected);
marker.pointDescription, marker.colorIndex, marker.selected);
if (refresh) {
readFromSettings();
refresh();
@ -387,7 +346,7 @@ public class MapMarkersHelper {
public void moveMapMarker(@Nullable MapMarker marker, LatLon latLon) {
if (marker != null) {
settings.moveMapMarker(new LatLon(marker.getLatitude(), marker.getLongitude()), latLon,
marker.pointDescription, marker.colorIndex, marker.pos, marker.selected);
marker.pointDescription, marker.colorIndex, marker.selected);
marker.point = new LatLon(latLon.getLatitude(), latLon.getLongitude());
readFromSettings();
refresh();
@ -423,16 +382,14 @@ public class MapMarkersHelper {
List<LatLon> ls = new ArrayList<>(markers.size());
List<String> names = new ArrayList<>(markers.size());
List<Integer> colors = new ArrayList<>(markers.size());
List<Integer> positions = new ArrayList<>(markers.size());
List<Boolean> selections = new ArrayList<>(markers.size());
for (MapMarker marker : markers) {
ls.add(marker.point);
names.add(PointDescription.serializeToString(marker.pointDescription));
colors.add(marker.colorIndex);
positions.add(marker.pos);
selections.add(marker.selected);
}
settings.saveMapMarkers(ls, names, colors, positions, selections);
settings.saveMapMarkers(ls, names, colors, selections);
}
if (markersHistory != null) {

View file

@ -1731,7 +1731,6 @@ public class OsmandSettings {
public final static String MAP_MARKERS_POINT = "map_markers_point"; //$NON-NLS-1$
public final static String MAP_MARKERS_COLOR = "map_markers_color"; //$NON-NLS-1$
public final static String MAP_MARKERS_DESCRIPTION = "map_markers_description"; //$NON-NLS-1$
public final static String MAP_MARKERS_POSITION = "map_markers_position"; //$NON-NLS-1$
public final static String MAP_MARKERS_SELECTION = "map_markers_selection"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_POINT = "map_markers_history_point"; //$NON-NLS-1$
public final static String MAP_MARKERS_HISTORY_DESCRIPTION = "map_markers_history_description"; //$NON-NLS-1$
@ -1845,7 +1844,6 @@ public class OsmandSettings {
.remove(MAP_MARKERS_POINT)
.remove(MAP_MARKERS_DESCRIPTION)
.remove(MAP_MARKERS_COLOR)
.remove(MAP_MARKERS_POSITION)
.remove(MAP_MARKERS_SELECTION)
.commit();
}
@ -1896,14 +1894,12 @@ public class OsmandSettings {
private class MapMarkersStorage extends MapPointsStorage {
protected String colorsKey;
protected String posKey;
protected String selectionKey;
public MapMarkersStorage() {
pointsKey = MAP_MARKERS_POINT;
descriptionsKey = MAP_MARKERS_DESCRIPTION;
colorsKey = MAP_MARKERS_COLOR;
posKey = MAP_MARKERS_POSITION;
selectionKey = MAP_MARKERS_SELECTION;
}
@ -1928,30 +1924,6 @@ public class OsmandSettings {
return list;
}
public List<Integer> getPositions(int sz) {
List<Integer> list = new ArrayList<>();
int pos = 0;
String ip = settingsAPI.getString(globalPreferences, posKey, "");
if (ip.trim().length() > 0) {
StringTokenizer tok = new StringTokenizer(ip, ",");
while (tok.hasMoreTokens()) {
String indexStr = tok.nextToken();
int p = Integer.parseInt(indexStr);
list.add(p);
if (p > pos) {
pos = p;
}
}
}
while (list.size() > sz) {
list.remove(list.size() - 1);
}
while (list.size() < sz) {
list.add(++pos);
}
return list;
}
public List<Boolean> getSelections(int sz) {
List<Boolean> list = new ArrayList<>();
String ip = settingsAPI.getString(globalPreferences, selectionKey, "");
@ -1977,17 +1949,15 @@ public class OsmandSettings {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
ns.add(index, pos);
bs.add(index, selected);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
return savePoints(ps, ds, cs, ns, bs);
return savePoints(ps, ds, cs, bs);
}
public boolean insertPoints(double[] latitudes, double[] longitudes,
@ -1996,35 +1966,31 @@ public class OsmandSettings {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
for (int i = 0; i < latitudes.length; i++) {
double latitude = latitudes[i];
double longitude = longitudes[i];
PointDescription historyDescription = historyDescriptions.get(i);
int colorIndex = colorIndexes[i];
int pos = positions[i];
boolean selected = selections[i];
int index = indexes[i];
ps.add(index, new LatLon(latitude, longitude));
ds.add(index, PointDescription.serializeToString(historyDescription));
cs.add(index, colorIndex);
ns.add(index, pos);
bs.add(index, selected);
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
}
return savePoints(ps, ds, cs, ns, bs);
return savePoints(ps, ds, cs, bs);
}
public boolean updatePoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex,
int pos, boolean selected) {
boolean selected) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
int index = ps.indexOf(new LatLon(latitude, longitude));
if (index != -1) {
@ -2032,16 +1998,13 @@ public class OsmandSettings {
if (cs.size() > index) {
cs.set(index, colorIndex);
}
if (ns.size() > index) {
ns.set(index, pos);
}
if (bs.size() > index) {
bs.set(index, selected);
}
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
}
return savePoints(ps, ds, cs, ns, bs);
return savePoints(ps, ds, cs, bs);
} else {
return false;
}
@ -2051,12 +2014,10 @@ public class OsmandSettings {
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
int pos,
boolean selected) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
int index = ps.indexOf(latLonEx);
if (index != -1) {
@ -2067,9 +2028,6 @@ public class OsmandSettings {
if (cs.size() > index) {
cs.set(index, colorIndex);
}
if (ns.size() > index) {
ns.set(index, pos);
}
if (bs.size() > index) {
bs.set(index, selected);
}
@ -2078,7 +2036,7 @@ public class OsmandSettings {
double lon = latLonNew.getLongitude();
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(lat, lon, historyDescription);
}
return savePoints(ps, ds, cs, ns, bs);
return savePoints(ps, ds, cs, bs);
} else {
return false;
}
@ -2089,24 +2047,20 @@ public class OsmandSettings {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
List<Integer> ns = getPositions(ps.size());
List<Boolean> bs = getSelections(ps.size());
ps.remove(index);
ds.remove(index);
if (cs.size() > index) {
cs.remove(index);
}
if (ns.size() > index) {
ns.remove(index);
}
if (bs.size() > index) {
bs.remove(index);
}
return savePoints(ps, ds, cs, ns, bs);
return savePoints(ps, ds, cs, bs);
}
public boolean savePoints(List<LatLon> ps, List<String> ds, List<Integer> cs,
List<Integer> ns, List<Boolean> bs) {
List<Boolean> bs) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ps.size(); i++) {
if (i > 0) {
@ -2132,15 +2086,6 @@ public class OsmandSettings {
}
cb.append(Integer.toString(cs.get(i)));
}
StringBuilder nb = new StringBuilder();
if (ns != null) {
for (int i = 0; i < ns.size(); i++) {
if (i > 0) {
nb.append(",");
}
nb.append(Integer.toString(ns.get(i)));
}
}
StringBuilder bb = new StringBuilder();
if (bs != null) {
for (int i = 0; i < bs.size(); i++) {
@ -2154,7 +2099,6 @@ public class OsmandSettings {
.putString(pointsKey, sb.toString())
.putString(descriptionsKey, tb.toString())
.putString(colorsKey, cb.toString())
.putString(posKey, nb.toString())
.putString(selectionKey, bb.toString())
.commit();
}
@ -2345,10 +2289,6 @@ public class OsmandSettings {
return mapMarkersStorage.getColors(sz);
}
public List<Integer> getMapMarkersPositions(int sz) {
return mapMarkersStorage.getPositions(sz);
}
public List<Boolean> getMapMarkersSelections(int sz) {
return mapMarkersStorage.getSelections(sz);
}
@ -2372,29 +2312,24 @@ public class OsmandSettings {
}
public boolean updateMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex,
int pos, boolean selected) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex,
pos, selected);
PointDescription historyDescription, int colorIndex, boolean selected) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex, selected);
}
public boolean moveMapMarker(LatLon latLonEx,
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
int pos,
boolean selected) {
return mapMarkersStorage.movePoint(latLonEx, latLonNew, historyDescription, colorIndex,
pos, selected);
return mapMarkersStorage.movePoint(latLonEx, latLonNew, historyDescription, colorIndex, selected);
}
public boolean deleteMapMarker(int index) {
return mapMarkersStorage.deletePoint(index);
}
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Integer> ns,
List<Boolean> bs) {
return mapMarkersStorage.savePoints(ps, ds, cs, ns, bs);
public boolean saveMapMarkers(List<LatLon> ps, List<String> ds, List<Integer> cs, List<Boolean> bs) {
return mapMarkersStorage.savePoints(ps, ds, cs, bs);
}

View file

@ -924,8 +924,8 @@ public class MapActivityActions implements DialogProvider {
}
public void setFirstMapMarkerAsTarget() {
if (getMyApplication().getMapMarkersHelper().getSortedMapMarkers().size() > 0) {
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getSortedMapMarkers().get(0);
if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers().get(0);
PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription.isLocation()
&& pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(mapActivity))) {

View file

@ -90,7 +90,6 @@ import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import net.osmand.search.core.ObjectType;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -509,7 +508,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
if (visibleType == DashboardType.MAP_MARKERS || visibleType == DashboardType.MAP_MARKERS_SELECTION
&& getMyApplication().getMapMarkersHelper().getActiveMapMarkers().size() > 0) {
&& getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
sort.setVisibility(View.VISIBLE);
sort.setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -100,7 +100,7 @@ public class MapMarkerDialogHelper {
}
public boolean hasActiveMarkers() {
return markersHelper.getActiveMapMarkers().size() > 0;
return markersHelper.getMapMarkers().size() > 0;
}
public void setSelectionMode(boolean selectionMode) {
@ -166,7 +166,7 @@ public class MapMarkerDialogHelper {
List<Object> activeObjects = getActiveObjects(objects);
allSelected = true;
List<MapMarker> activeMarkers = new ArrayList<>(markersHelper.getActiveMapMarkers());
List<MapMarker> activeMarkers = new ArrayList<>(markersHelper.getMapMarkers());
for (MapMarker m : activeMarkers) {
if (!m.selected) {
allSelected = false;
@ -290,7 +290,7 @@ public class MapMarkerDialogHelper {
public void onClick(DialogInterface dialog, int which) {
listAdapter.notifyDataSetInvalidated();
markersHelper.removeMarkersHistory();
if (markersHelper.getActiveMapMarkers().size() == 0) {
if (markersHelper.getMapMarkers().size() == 0) {
mapActivity.getDashboard().hideDashboard();
} else if (helperCallbacks != null) {
helperCallbacks.reloadAdapter();
@ -318,7 +318,7 @@ public class MapMarkerDialogHelper {
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<MapMarker> markers = markersHelper.getActiveMapMarkers();
List<MapMarker> markers = markersHelper.getMapMarkers();
for (MapMarker marker : markers) {
marker.selected = !allSelected;
}
@ -371,7 +371,7 @@ public class MapMarkerDialogHelper {
}
});
if (!sorted && markersHelper.getActiveMapMarkers().size() > 1) {
if (!sorted && markersHelper.getMapMarkers().size() > 1) {
item = optionsMenu.getMenu().add(R.string.shared_string_reverse_order).setIcon(
iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@ -393,7 +393,7 @@ public class MapMarkerDialogHelper {
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
generateGPX(markersHelper.getActiveMapMarkers());
generateGPX(markersHelper.getMapMarkers());
return true;
}
});
@ -745,7 +745,7 @@ public class MapMarkerDialogHelper {
LatLon mapLocation =
new LatLon(mapActivity.getMapView().getLatitude(), mapActivity.getMapView().getLongitude());
List<MapMarker> activeMarkers = new ArrayList<>(markersHelper.getActiveMapMarkers());
List<MapMarker> activeMarkers = new ArrayList<>(markersHelper.getMapMarkers());
calcDistance(mapLocation, activeMarkers);
if (sorted) {
Collections.sort(activeMarkers, new Comparator<MapMarker>() {
@ -899,7 +899,7 @@ public class MapMarkerDialogHelper {
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
}
GPXFile file = new GPXFile();
for (MapMarker marker : markersHelper.getActiveMapMarkers()) {
for (MapMarker marker : markersHelper.getMapMarkers()) {
WptPt wpt = new WptPt();
wpt.lat = marker.getLatitude();
wpt.lon = marker.getLongitude();

View file

@ -458,7 +458,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void selectMapMarker(final int index, final boolean target) {
if (index != -1) {
MapMarker m = mapActivity.getMyApplication().getMapMarkersHelper().getActiveMapMarkers().get(index);
MapMarker m = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers().get(index);
LatLon point = new LatLon(m.getLatitude(), m.getLongitude());
if (target) {
getTargets().navigateToPoint(point, true, -1, m.getPointDescription(mapActivity));
@ -794,7 +794,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void addMarkersToSpinner(List<RouteSpinnerRow> actions) {
MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
List<MapMarker> markers = markersHelper.getActiveMapMarkers();
List<MapMarker> markers = markersHelper.getMapMarkers();
if (markers.size() > 0) {
MapMarker m = markers.get(0);
actions.add(new RouteSpinnerRow(SPINNER_MAP_MARKER_1_ID,

View file

@ -89,7 +89,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getActiveMapMarkers();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getMapMarkers();
if (markers.size() > 0) {
for (MapMarker marker : markers) {
adapter.add(marker);

View file

@ -258,7 +258,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
canvas.drawPath(path, paint);
}
List<MapMarker> activeMapMarkers = markersHelper.getActiveMapMarkers();
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
for (MapMarker marker : activeMapMarkers) {
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker)
&& !isInMotion(marker)) {
@ -282,9 +282,9 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
loc = tileBox.getCenterLatLon();
}
if (loc != null) {
List<MapMarker> sortedMapMarkers = markersHelper.getSortedMapMarkers();
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
int i = 0;
for (MapMarker marker : sortedMapMarkers) {
for (MapMarker marker : mapMarkers) {
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
canvas.save();
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(),
@ -432,7 +432,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
}
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
List<MapMarker> markers = markersHelper.getActiveMapMarkers();
List<MapMarker> markers = markersHelper.getMapMarkers();
int r = getRadiusPoi(tileBox);
for (int i = 0; i < markers.size(); i++) {
MapMarker marker = markers.get(i);
@ -495,12 +495,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
if (o instanceof MapMarker) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
MapMarker marker = (MapMarker) o;
List<MapMarker> sortedMarkers = markersHelper.getSortedMapMarkers();
int i = sortedMarkers.indexOf(marker);
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
int i = mapMarkers.indexOf(marker);
if (i != -1) {
sortedMarkers.remove(i);
sortedMarkers.add(0, marker);
markersHelper.normalizePositions();
mapMarkers.remove(i);
mapMarkers.add(0, marker);
markersHelper.saveMapMarkers(mapMarkers, null);
}
}
}
@ -525,9 +525,9 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
marker.getOriginalPointDescription().setName(PointDescription.getSearchAddressStr(map));
markersHelper.moveMapMarker(marker, position);
int index = markersHelper.getActiveMapMarkers().indexOf(marker);
int index = markersHelper.getMapMarkers().indexOf(marker);
if (index != -1) {
newObject = markersHelper.getActiveMapMarkers().get(index);
newObject = markersHelper.getMapMarkers().get(index);
}
result = true;
}

View file

@ -93,7 +93,7 @@ public class MapMarkersWidgetsFactory {
});
IconsCache iconsCache = map.getMyApplication().getIconsCache();
if (isLandscapeLayout() && helper.getSortedMapMarkers().size() > 1) {
if (isLandscapeLayout() && helper.getMapMarkers().size() > 1) {
moreButton.setVisibility(View.GONE);
} else {
moreButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_overflow_menu_white, R.color.marker_top_2nd_line_color));
@ -132,16 +132,16 @@ public class MapMarkersWidgetsFactory {
}
private void removeMarker(int index) {
if (helper.getSortedMapMarkers().size() > index) {
MapMarker marker = helper.getSortedMapMarkers().get(index);
if (helper.getMapMarkers().size() > index) {
MapMarker marker = helper.getMapMarkers().get(index);
helper.removeMapMarker(marker.index);
helper.addMapMarkerHistory(marker);
}
}
private void showMarkerOnMap(int index) {
if (helper.getSortedMapMarkers().size() > index) {
MapMarker marker = helper.getSortedMapMarkers().get(index);
if (helper.getMapMarkers().size() > index) {
MapMarker marker = helper.getMapMarkers().get(index);
AnimateDraggingMapThread thread = map.getMapView().getAnimatedDraggingThread();
LatLon pointToNavigate = marker.point;
if (pointToNavigate != null) {
@ -195,7 +195,7 @@ public class MapMarkersWidgetsFactory {
}
}
List<MapMarker> markers = helper.getSortedMapMarkers();
List<MapMarker> markers = helper.getMapMarkers();
if (zoom < 3 || markers.size() == 0
|| !map.getMyApplication().getSettings().MAP_MARKERS_MODE.get().isToolbar()
|| map.getMyApplication().getRoutingHelper().isFollowingMode()
@ -385,7 +385,7 @@ public class MapMarkersWidgetsFactory {
}
private MapMarker getMarker() {
List<MapMarker> markers = helper.getSortedMapMarkers();
List<MapMarker> markers = helper.getMapMarkers();
if (firstMarker) {
if (markers.size() > 0) {
return markers.get(0);

View file

@ -672,7 +672,7 @@ public class RouteInfoWidgetsFactory {
Location myLocation = getOsmandApplication().getLocationProvider().getLastKnownLocation();
LatLon l = getPointToNavigate();
if (l == null) {
List<MapMarker> markers = getOsmandApplication().getMapMarkersHelper().getSortedMapMarkers();
List<MapMarker> markers = getOsmandApplication().getMapMarkersHelper().getMapMarkers();
if (markers.size() > 0) {
l = markers.get(0).point;
}