diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 5d9e0db424..e518d6a1f5 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -408,7 +408,7 @@ public class FavouritesDbHelper { if (p.getOriginObjectName().length() > 0) { pt.comment = p.getOriginObjectName(); } - gpx.points.add(pt); + gpx.addPoint(pt); } return gpx; } @@ -560,7 +560,7 @@ public class FavouritesDbHelper { if (res.warning != null) { return false; } - for (WptPt p : res.points) { + for (WptPt p : res.getPoints()) { int c; String name = p.name; String categoryName = p.category != null ? p.category : ""; diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 4cd24455c3..6142368163 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -39,6 +39,7 @@ import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.LinkedHashMap; @@ -745,7 +746,7 @@ public class GPXUtilities { public static class GPXFile extends GPXExtensions { public String author; public List tracks = new ArrayList<>(); - public List points = new ArrayList<>(); + private List points = new ArrayList<>(); public List routes = new ArrayList<>(); public String warning = null; @@ -756,6 +757,26 @@ public class GPXUtilities { private Track generalTrack; private TrkSegment generalSegment; + public List getPoints() { + return points; + } + + public void clearPoints() { + points.clear(); + } + + public void addPoint(WptPt point) { + points.add(point); + } + + public void addAllPoints(Collection collection) { + points.addAll(collection); + } + + public boolean removePoint(WptPt point) { + return points.remove(point); + } + public boolean isCloudmadeRouteFile() { return "cloudmade".equalsIgnoreCase(author); } @@ -1200,7 +1221,7 @@ public class GPXUtilities { serializer.endTag(null, "rte"); //$NON-NLS-1$ } - for (WptPt l : file.points) { + for (WptPt l : file.getPoints()) { serializer.startTag(null, "wpt"); //$NON-NLS-1$ writeWpt(format, serializer, l); serializer.endTag(null, "wpt"); //$NON-NLS-1$ @@ -1381,7 +1402,7 @@ public class GPXUtilities { } if (parser.getName().equals("wpt")) { WptPt wptPt = parseWptAttributes(parser); - ((GPXFile) parse).points.add(wptPt); + ((GPXFile) parse).addPoint(wptPt); parserState.push(wptPt); } } else if (parse instanceof Route) { @@ -1556,8 +1577,8 @@ public class GPXUtilities { if (from.showCurrentTrack) { to.showCurrentTrack = true; } - if (from.points != null) { - to.points.addAll(from.points); + if (from.getPoints() != null) { + to.addAllPoints(from.getPoints()); } if (from.tracks != null) { to.tracks.addAll(from.tracks); diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 5fcb91e40d..1e1d1d6faa 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -76,7 +76,7 @@ public class GpxSelectionHelper { public SelectedGpxFile getSelectedGPXFile(WptPt point) { for (SelectedGpxFile g : selectedGPXFiles) { - if (g.getGpxFile().points.contains(point)) { + if (g.getGpxFile().getPoints().contains(point)) { return g; } } @@ -214,16 +214,16 @@ public class GpxSelectionHelper { } } - if (g.points.size() > 0) { + if (g.getPoints().size() > 0) { GpxDisplayGroup group = new GpxDisplayGroup(g); group.gpxName = name; group.setType(GpxDisplayItemType.TRACK_POINTS); - group.setDescription(getString(R.string.gpx_selection_number_of_points, g.points.size())); + group.setDescription(getString(R.string.gpx_selection_number_of_points, g.getPoints().size())); group.setName(getString(R.string.gpx_selection_points, name)); dg.add(group); List list = group.getModifiableList(); int k = 0; - for (WptPt r : g.points) { + for (WptPt r : g.getPoints()) { GpxDisplayItem item = new GpxDisplayItem(); item.group = group; item.description = r.desc; diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 464c2626fd..1c17330aba 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -4,6 +4,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.text.format.DateFormat; + import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.plus.GPXDatabase.GpxDataItem; @@ -19,7 +20,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; -import net.osmand.plus.notifications.OsmandNotification; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.util.MapUtils; @@ -252,7 +252,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { distance = 0; points = 0; duration = 0; - currentTrack.getModifiableGpxFile().points.clear(); + currentTrack.getModifiableGpxFile().clearPoints(); currentTrack.getModifiableGpxFile().tracks.clear(); currentTrack.getModifiablePointsToDisplay().clear(); currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis(); @@ -305,7 +305,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { gpx = new GPXFile(); dataTracks.put(date, gpx); } - gpx.points.add(pt); + gpx.addPoint(pt); } while (query.moveToNext()); } @@ -469,7 +469,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { if (color != 0) { pt.setColor(color); } - currentTrack.getModifiableGpxFile().points.add(pt); + currentTrack.getModifiableGpxFile().addPoint(pt); currentTrack.getModifiableGpxFile().modifiedTime = time; points++; execWithClose(insertPointsScript, new Object[] { lat, lon, time, description, name, category, color }); @@ -541,7 +541,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } public void deletePointData(WptPt pt) { - currentTrack.getModifiableGpxFile().points.remove(pt); + currentTrack.getModifiableGpxFile().removePoint(pt); currentTrack.getModifiableGpxFile().modifiedTime = System.currentTimeMillis(); points--; @@ -598,7 +598,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { Map files = collectRecordedData(); currentTrack.getModifiableGpxFile().tracks.clear(); for (Map.Entry entry : files.entrySet()){ - currentTrack.getModifiableGpxFile().points.addAll(entry.getValue().points); + currentTrack.getModifiableGpxFile().addAllPoints(entry.getValue().getPoints()); currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks); } currentTrack.processPoints(); diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index aff88e1662..0cd778acb5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.support.v7.widget.Toolbar; @@ -18,8 +17,8 @@ import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GPXUtilities; -import net.osmand.plus.GPXUtilities.TrkSegment; import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.TrkSegment; import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; @@ -159,7 +158,7 @@ public class TrackActivity extends TabActivity { } } } - for (WptPt p : getGpx().points) { + for (WptPt p : getGpx().getPoints()) { if (left == 0 && right == 0) { left = p.getLongitude(); right = p.getLongitude(); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index 6f02d6dde7..136d370c4f 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -311,7 +311,7 @@ public class NotesFragment extends OsmAndListFragment { wpt.link = r.getFileName(); wpt.time = r.getFile().lastModified(); wpt.category = r.getSearchHistoryType(); - file.points.add(wpt); + file.addPoint(wpt); } } GPXUtilities.writeGpxFile(tmpFile, file, getMyApplication()); diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java index a119bbaa1c..58cb85284e 100644 --- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java +++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java @@ -236,7 +236,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { LinkedList l = new LinkedList(r.points); measurementPoints.add(l); } - for (WptPt p : result.points) { + for (WptPt p : result.getPoints()) { LinkedList l = new LinkedList(); l.add(p); measurementPoints.add(l); @@ -336,14 +336,14 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { saveTrackToRte = originalGPX.routes.size() > 0 && originalGPX.tracks.size() == 0; gpx.tracks.clear(); gpx.routes.clear(); - gpx.points.clear(); + gpx.clearPoints(); } else { gpx = new GPXFile(); } for (int i = 0; i < measurementPoints.size(); i++) { LinkedList lt = measurementPoints.get(i); if (lt.size() == 1) { - gpx.points.add(lt.getFirst()); + gpx.addPoint(lt.getFirst()); } else if (lt.size() > 1) { if (saveTrackToRte) { Route rt = new Route(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java index c42960194b..6a7b158f01 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxImportHelper.java @@ -225,7 +225,7 @@ public class GpxImportHelper { @Override protected GPXFile doInBackground(Void... nothing) { - final List favourites = asFavourites(gpxFile.points, fileName, forceImportFavourites); + final List favourites = asFavourites(gpxFile.getPoints(), fileName, forceImportFavourites); final FavouritesDbHelper favoritesHelper = app.getFavorites(); for (final FavouritePoint favourite : favourites) { favoritesHelper.deleteFavourite(favourite, false); @@ -492,7 +492,7 @@ public class GpxImportHelper { private void importFavourites(final GPXFile gpxFile, final String fileName, final boolean save, final boolean useImportDir, final boolean forceImportFavourites) { - if (gpxFile == null || gpxFile.points == null || gpxFile.points.size() == 0) { + if (gpxFile == null || gpxFile.getPoints() == null || gpxFile.getPoints().size() == 0) { if (forceImportFavourites) { final DialogInterface.OnClickListener importAsTrackListener = new DialogInterface.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index 35823dfcba..93eb2b819d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -870,7 +870,7 @@ public class MapMarkerDialogHelper { //wpt.link = r.getFileName(); //wpt.time = r.getFile().lastModified(); //wpt.category = r.getSearchHistoryType(); - file.points.add(wpt); + file.addPoint(wpt); } GPXUtilities.writeGpxFile(fout, file, app); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index ba5ec52e89..b3166dc624 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -702,7 +702,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { } private void drawPoints(Canvas canvas, RotatedTileBox tileBox, SelectedGpxFile g) { - List pts = g.getGpxFile().points; + List pts = g.getGpxFile().getPoints(); @ColorInt int fileColor = g.getColor() == 0 ? defPointColor : g.getColor(); for (WptPt o : pts) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 8e2b5fa2db..96431875cf 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -345,14 +345,14 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor { } for (WptPt point : params) { if (point.deleted) { - for (WptPt pointInTrack : g.points) { + for (WptPt pointInTrack : g.getPoints()) { if (pointInTrack.getExtensionsToRead().get("u").equals( point.getExtensionsToRead().get("u"))) { - g.points.remove(pointInTrack); + g.removePoint(pointInTrack); } } } else { - g.points.add(point); + g.addPoint(point); } } errors = GPXUtilities.writeGpxFile(ps, g, app); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 57d1ae0e60..fed4966a67 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -238,8 +238,8 @@ public class RouteProvider { calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts; useIntermediatePointsRTE = builder.useIntermediatePointsRTE; builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute; - if (!file.points.isEmpty()) { - wpt = new ArrayList(file.points); + if (!file.getPoints().isEmpty()) { + wpt = new ArrayList(file.getPoints()); } if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) { directions = parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10); @@ -845,7 +845,7 @@ public class RouteProvider { boolean leftSide, float defSpeed) { List directions = null; if (!osmandRouter) { - for (WptPt pt : gpxFile.points) { + for (WptPt pt : gpxFile.getPoints()) { res.add(createLocation(pt)); } } else { @@ -1092,7 +1092,7 @@ public class RouteProvider { } pt.desc = pt.name; } - gpx.points.add(pt); + gpx.addPoint(pt); } return gpx; } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 95c3981cbb..2e92e7dc81 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -1887,7 +1887,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC if (hasTypeInDescription) { pt.desc = h.getName().getTypeName(); } - gpx.points.add(pt); + gpx.addPoint(pt); } return gpx; } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java index 4f97f07c11..f2c5c9384d 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchHelper.java @@ -118,7 +118,7 @@ public class QuickSearchHelper implements ResourceListener { List list = app.getSelectedGpxHelper().getSelectedGPXFiles(); for (GpxSelectionHelper.SelectedGpxFile selectedGpx : list) { if (selectedGpx != null) { - for (GPXUtilities.WptPt point : selectedGpx.getGpxFile().points) { + for (GPXUtilities.WptPt point : selectedGpx.getGpxFile().getPoints()) { SearchResult sr = new SearchResult(phrase); sr.localeName = point.getPointDescription(app).getName(); sr.object = point; diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 7933b0d696..3957c50e36 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -501,7 +501,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } private List getListStarPoints(SelectedGpxFile g) { - return g.getGpxFile().points; + return g.getGpxFile().getPoints(); } private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {