Fix issue 900. Update latest GPX track while display
This commit is contained in:
parent
ffa149b460
commit
78d624b008
9 changed files with 78 additions and 85 deletions
|
@ -246,10 +246,22 @@ public class GPXUtilities {
|
||||||
public String warning = null;
|
public String warning = null;
|
||||||
public String path = "";
|
public String path = "";
|
||||||
|
|
||||||
|
public List<List<WptPt>> processedPointsToDisplay = new ArrayList<List<WptPt>>();
|
||||||
|
|
||||||
public boolean isCloudmadeRouteFile(){
|
public boolean isCloudmadeRouteFile(){
|
||||||
return "cloudmade".equalsIgnoreCase(author);
|
return "cloudmade".equalsIgnoreCase(author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void proccessPoints(){
|
||||||
|
List<List<WptPt>> tpoints = new ArrayList<List<WptPt>>();
|
||||||
|
for (Track t : tracks) {
|
||||||
|
for (TrkSegment ts : t.segments) {
|
||||||
|
tpoints.add(ts.points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
processedPointsToDisplay = tpoints;
|
||||||
|
}
|
||||||
|
|
||||||
public WptPt findPointToShow(){
|
public WptPt findPointToShow(){
|
||||||
for(Track t : tracks){
|
for(Track t : tracks){
|
||||||
for(TrkSegment s : t.segments){
|
for(TrkSegment s : t.segments){
|
||||||
|
|
|
@ -95,8 +95,8 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get();
|
serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get();
|
||||||
serviceOffProvider = settings.SERVICE_OFF_PROVIDER.get();
|
serviceOffProvider = settings.SERVICE_OFF_PROVIDER.get();
|
||||||
serviceError = settings.SERVICE_OFF_WAIT_INTERVAL.get();
|
serviceError = settings.SERVICE_OFF_WAIT_INTERVAL.get();
|
||||||
savingTrackHelper = new SavingTrackHelper(this);
|
savingTrackHelper = ((OsmandApplication) getApplication()).getSavingTrackHelper();
|
||||||
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
liveMonitoringHelper = ((OsmandApplication) getApplication()).getLiveMonitoringHelper();
|
||||||
|
|
||||||
routingHelper = ((OsmandApplication)getApplication()).getRoutingHelper();
|
routingHelper = ((OsmandApplication)getApplication()).getRoutingHelper();
|
||||||
((OsmandApplication)getApplication()).setNavigationService(this);
|
((OsmandApplication)getApplication()).setNavigationService(this);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.LogUtil;
|
||||||
import net.osmand.access.AccessibilityMode;
|
import net.osmand.access.AccessibilityMode;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.activities.DayNightHelper;
|
import net.osmand.plus.activities.DayNightHelper;
|
||||||
|
import net.osmand.plus.activities.LiveMonitoringHelper;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||||
|
@ -71,9 +72,12 @@ public class OsmandApplication extends Application {
|
||||||
private List<String> startingWarnings;
|
private List<String> startingWarnings;
|
||||||
private Handler uiHandler;
|
private Handler uiHandler;
|
||||||
private GPXFile gpxFileToDisplay;
|
private GPXFile gpxFileToDisplay;
|
||||||
|
private SavingTrackHelper savingTrackHelper;
|
||||||
|
private LiveMonitoringHelper liveMonitoringHelper;
|
||||||
|
|
||||||
private boolean applicationInitializing = false;
|
private boolean applicationInitializing = false;
|
||||||
private Locale prefferedLocale = null;
|
private Locale prefferedLocale = null;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
|
@ -85,6 +89,8 @@ public class OsmandApplication extends Application {
|
||||||
manager = new ResourceManager(this);
|
manager = new ResourceManager(this);
|
||||||
daynightHelper = new DayNightHelper(this);
|
daynightHelper = new DayNightHelper(this);
|
||||||
bidforfix = new BidForFixHelper("osmand.net", getString(R.string.default_buttons_support), getString(R.string.default_buttons_cancel));
|
bidforfix = new BidForFixHelper("osmand.net", getString(R.string.default_buttons_support), getString(R.string.default_buttons_cancel));
|
||||||
|
savingTrackHelper = new SavingTrackHelper(this);
|
||||||
|
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
||||||
uiHandler = new Handler();
|
uiHandler = new Handler();
|
||||||
rendererRegistry = new RendererRegistry();
|
rendererRegistry = new RendererRegistry();
|
||||||
checkPrefferedLocale();
|
checkPrefferedLocale();
|
||||||
|
@ -134,6 +140,14 @@ public class OsmandApplication extends Application {
|
||||||
return osmandSettings;
|
return osmandSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SavingTrackHelper getSavingTrackHelper() {
|
||||||
|
return savingTrackHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveMonitoringHelper getLiveMonitoringHelper() {
|
||||||
|
return liveMonitoringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PoiFiltersHelper getPoiFilters() {
|
public PoiFiltersHelper getPoiFilters() {
|
||||||
if (poiFilters == null) {
|
if (poiFilters == null) {
|
||||||
|
@ -159,6 +173,7 @@ public class OsmandApplication extends Application {
|
||||||
pt.setName(p.name);
|
pt.setName(p.name);
|
||||||
pts.add(pt);
|
pts.add(pt);
|
||||||
}
|
}
|
||||||
|
gpxFileToDisplay.proccessPoints();
|
||||||
getFavorites().setFavoritePointsFromGPXFile(pts);
|
getFavorites().setFavoritePointsFromGPXFile(pts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,12 +402,11 @@ public class OsmandApplication extends Application {
|
||||||
}
|
}
|
||||||
warnings.addAll(manager.reloadIndexes(startDialog));
|
warnings.addAll(manager.reloadIndexes(startDialog));
|
||||||
player = null;
|
player = null;
|
||||||
SavingTrackHelper helper = new SavingTrackHelper(OsmandApplication.this);
|
if (savingTrackHelper.hasDataToSave()) {
|
||||||
if (helper.hasDataToSave()) {
|
|
||||||
startDialog.startTask(getString(R.string.saving_gpx_tracks), -1);
|
startDialog.startTask(getString(R.string.saving_gpx_tracks), -1);
|
||||||
warnings.addAll(helper.saveDataToGpx());
|
warnings.addAll(savingTrackHelper.saveDataToGpx());
|
||||||
}
|
}
|
||||||
helper.close();
|
savingTrackHelper.close();
|
||||||
|
|
||||||
// restore backuped favorites to normal file
|
// restore backuped favorites to normal file
|
||||||
final File appDir = getSettings().extendOsmandPath(ResourceManager.APP_DIR);
|
final File appDir = getSettings().extendOsmandPath(ResourceManager.APP_DIR);
|
||||||
|
|
|
@ -198,8 +198,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
savingTrackHelper = new SavingTrackHelper(this);
|
savingTrackHelper = getMyApplication().getSavingTrackHelper();
|
||||||
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
liveMonitoringHelper = getMyApplication().getLiveMonitoringHelper();
|
||||||
LatLon pointToNavigate = settings.getPointToNavigate();
|
LatLon pointToNavigate = settings.getPointToNavigate();
|
||||||
|
|
||||||
routingHelper = getMyApplication().getRoutingHelper();
|
routingHelper = getMyApplication().getRoutingHelper();
|
||||||
|
@ -750,11 +750,6 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
if (settings.SAVE_TRACK_TO_GPX.get()) {
|
if (settings.SAVE_TRACK_TO_GPX.get()) {
|
||||||
savingTrackHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(),
|
savingTrackHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(),
|
||||||
location.getSpeed(), location.getAccuracy(), locationTime, settings);
|
location.getSpeed(), location.getAccuracy(), locationTime, settings);
|
||||||
if (settings.SHOW_CURRENT_GPX_TRACK.get()) {
|
|
||||||
WptPt pt = new GPXUtilities.WptPt(location.getLatitude(), location.getLongitude(), locationTime,
|
|
||||||
location.getAltitude(), location.getSpeed(), location.getAccuracy());
|
|
||||||
mapLayers.getGpxLayer().addTrackPoint(pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(settings.LIVE_MONITORING.get()){
|
if(settings.LIVE_MONITORING.get()){
|
||||||
|
|
|
@ -186,7 +186,6 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsmandPlugin.refreshLayers(mapView, activity);
|
OsmandPlugin.refreshLayers(mapView, activity);
|
||||||
updateGPXLayer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMapSource(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap){
|
public void updateMapSource(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap){
|
||||||
|
@ -262,7 +261,6 @@ public class MapActivityLayers {
|
||||||
} else if(itemId == R.string.layer_gpx_layer){
|
} else if(itemId == R.string.layer_gpx_layer){
|
||||||
if(getApplication().getGpxFileToDisplay() != null){
|
if(getApplication().getGpxFileToDisplay() != null){
|
||||||
getApplication().setGpxFileToDisplay(null, false);
|
getApplication().setGpxFileToDisplay(null, false);
|
||||||
gpxLayer.clearCurrentGPX();
|
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showGPXFileLayer(mapView);
|
showGPXFileLayer(mapView);
|
||||||
|
@ -365,22 +363,12 @@ public class MapActivityLayers {
|
||||||
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
||||||
mapView.getZoom(), true);
|
mapView.getZoom(), true);
|
||||||
}
|
}
|
||||||
updateGPXLayer();
|
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, true, true);
|
}, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGPXLayer(){
|
|
||||||
GPXFile gpxFileToDisplay = getApplication().getGpxFileToDisplay();
|
|
||||||
if(gpxFileToDisplay == null){
|
|
||||||
gpxLayer.setTracks(null);
|
|
||||||
} else {
|
|
||||||
gpxLayer.setTracks(gpxFileToDisplay.tracks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade,
|
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade,
|
||||||
final boolean showCurrentGpx) {
|
final boolean showCurrentGpx) {
|
||||||
final List<String> list = new ArrayList<String>();
|
final List<String> list = new ArrayList<String>();
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.osmand.plus.ResourceManager;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
@ -46,17 +45,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||||
|
|
||||||
public final static Log log = LogUtil.getLog(SavingTrackHelper.class);
|
public final static Log log = LogUtil.getLog(SavingTrackHelper.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String updateScript;
|
private String updateScript;
|
||||||
private String updatePointsScript;
|
private String updatePointsScript;
|
||||||
|
|
||||||
private long lastTimeUpdated = 0;
|
private long lastTimeUpdated = 0;
|
||||||
private final Context ctx;
|
private final OsmandApplication ctx;
|
||||||
|
|
||||||
public SavingTrackHelper(Context ctx){
|
public SavingTrackHelper(OsmandApplication ctx){
|
||||||
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
updateScript = "INSERT INTO " + TRACK_NAME +
|
updateScript = "INSERT INTO " + TRACK_NAME +
|
||||||
|
@ -257,6 +253,30 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) {
|
if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) {
|
||||||
execWithClose(updateScript, new Object[] { lat, lon, alt, speed, hdop, time });
|
execWithClose(updateScript, new Object[] { lat, lon, alt, speed, hdop, time });
|
||||||
lastTimeUpdated = time;
|
lastTimeUpdated = time;
|
||||||
|
if (settings.SHOW_CURRENT_GPX_TRACK.get()) {
|
||||||
|
WptPt pt = new GPXUtilities.WptPt(lat, lon, time,
|
||||||
|
alt, speed, hdop);
|
||||||
|
addTrackPoint(pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTrackPoint(WptPt pt) {
|
||||||
|
GPXFile file = ctx.getGpxFileToDisplay();
|
||||||
|
if (file != null && ctx.getSettings().SHOW_CURRENT_GPX_TRACK.get()) {
|
||||||
|
List<List<WptPt>> points = file.processedPointsToDisplay;
|
||||||
|
if (points.size() == 0) {
|
||||||
|
points.add(new ArrayList<WptPt>());
|
||||||
|
}
|
||||||
|
List<WptPt> last = points.get(points.size() - 1);
|
||||||
|
if (last.size() == 0 || last.get(last.size() - 1).time - pt.time < 6 * 60 * 1000) {
|
||||||
|
// 6 minutes same segment
|
||||||
|
last.add(pt);
|
||||||
|
} else {
|
||||||
|
ArrayList<WptPt> l = new ArrayList<WptPt>();
|
||||||
|
l.add(pt);
|
||||||
|
points.add(l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
SavingTrackHelper helper = new SavingTrackHelper(activity);
|
SavingTrackHelper helper = app.getSavingTrackHelper();
|
||||||
if (helper.hasDataToSave()) {
|
if (helper.hasDataToSave()) {
|
||||||
saveCurrentTracks(activity);
|
saveCurrentTracks(helper, activity);
|
||||||
} else {
|
} else {
|
||||||
helper.close();
|
helper.close();
|
||||||
}
|
}
|
||||||
|
@ -127,14 +127,13 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCurrentTracks(final SettingsActivity activity) {
|
private void saveCurrentTracks(final SavingTrackHelper helper, final SettingsActivity activity) {
|
||||||
activity.progressDlg = ProgressDialog.show(activity, activity.getString(R.string.saving_gpx_tracks), activity.getString(R.string.saving_gpx_tracks), true);
|
activity.progressDlg = ProgressDialog.show(activity, activity.getString(R.string.saving_gpx_tracks), activity.getString(R.string.saving_gpx_tracks), true);
|
||||||
final ProgressDialogImplementation impl = new ProgressDialogImplementation(activity.progressDlg);
|
final ProgressDialogImplementation impl = new ProgressDialogImplementation(activity.progressDlg);
|
||||||
impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$
|
impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
SavingTrackHelper helper = new SavingTrackHelper(activity);
|
|
||||||
helper.saveDataToGpx();
|
helper.saveDataToGpx();
|
||||||
helper.close();
|
helper.close();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.Track;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -22,16 +19,17 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
|
||||||
private List<List<WptPt>> points = new ArrayList<List<WptPt>>();
|
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
private boolean fluorescent;
|
||||||
|
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
|
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
|
||||||
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
||||||
paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent));
|
paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent));
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,11 +55,14 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
||||||
initUI(); //to change color immediately when needed
|
GPXFile gpxFile = view.getApplication().getGpxFileToDisplay();
|
||||||
List<List<WptPt>> points = this.points;
|
if(gpxFile == null){
|
||||||
if(points.isEmpty()){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<List<WptPt>> points = gpxFile.processedPointsToDisplay;
|
||||||
|
if(view.getSettings().FLUORESCENT_OVERLAYS.get() != fluorescent) {
|
||||||
|
initUI(); //to change color immediately when needed
|
||||||
|
}
|
||||||
|
|
||||||
for (List<WptPt> l : points) {
|
for (List<WptPt> l : points) {
|
||||||
path.rewind();
|
path.rewind();
|
||||||
|
@ -111,41 +112,6 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clearCurrentGPX(){
|
|
||||||
points.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTracks(List<Track> tracks){
|
|
||||||
if(tracks == null){
|
|
||||||
clearCurrentGPX();
|
|
||||||
} else {
|
|
||||||
List<List<WptPt>> tpoints = new ArrayList<List<WptPt>>();
|
|
||||||
for (Track t : tracks) {
|
|
||||||
for (TrkSegment ts : t.segments) {
|
|
||||||
tpoints.add(ts.points);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
points = tpoints;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTrackPoint(WptPt pt){
|
|
||||||
if(points.size() == 0){
|
|
||||||
points.add(new ArrayList<WptPt>());
|
|
||||||
}
|
|
||||||
List<WptPt> last = points.get(points.size() - 1);
|
|
||||||
if(last.size() == 0 || last.get(last.size() - 1).time - pt.time < 6 * 60 * 1000) {
|
|
||||||
// 6 minutes same segment
|
|
||||||
last.add(pt);
|
|
||||||
} else {
|
|
||||||
ArrayList<WptPt> l = new ArrayList<WptPt>();
|
|
||||||
l.add(pt);
|
|
||||||
points.add(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyLayer() {
|
public void destroyLayer() {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.views;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.LogUtil;
|
|
||||||
import net.osmand.osm.MapUtils;
|
import net.osmand.osm.MapUtils;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
@ -17,7 +16,6 @@ import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class RouteLayer extends OsmandMapLayer {
|
public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
@ -30,6 +28,8 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
|
private Boolean fluorescent;
|
||||||
|
|
||||||
public RouteLayer(RoutingHelper helper){
|
public RouteLayer(RoutingHelper helper){
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
|
@ -40,6 +40,7 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
|
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
|
||||||
tileRect = new RectF();
|
tileRect = new RectF();
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
|
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
|
||||||
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
||||||
paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent));
|
paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent));
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,10 +64,11 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
||||||
initUI(); //to change color immediately when needed
|
|
||||||
path.reset();
|
path.reset();
|
||||||
if (helper.hasPointsToShow()) {
|
if (helper.hasPointsToShow()) {
|
||||||
long time = System.currentTimeMillis();
|
if(view.getSettings().FLUORESCENT_OVERLAYS.get() != fluorescent) {
|
||||||
|
initUI(); //to change color immediately when needed
|
||||||
|
}
|
||||||
int w = view.getWidth();
|
int w = view.getWidth();
|
||||||
int h = view.getHeight();
|
int h = view.getHeight();
|
||||||
if(helper.getCurrentLocation() != null &&
|
if(helper.getCurrentLocation() != null &&
|
||||||
|
@ -84,9 +86,6 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
double lat = topLatitude - bottomLatitude + 0.1;
|
double lat = topLatitude - bottomLatitude + 0.1;
|
||||||
double lon = rightLongitude - leftLongitude + 0.1;
|
double lon = rightLongitude - leftLongitude + 0.1;
|
||||||
helper.fillLocationsToShow(topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon, points);
|
helper.fillLocationsToShow(topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon, points);
|
||||||
if((System.currentTimeMillis() - time) > 80){
|
|
||||||
Log.e(LogUtil.TAG, "Calculate route layer " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
if (points.size() > 0) {
|
if (points.size() > 0) {
|
||||||
int px = view.getMapXForPoint(points.get(0).getLongitude());
|
int px = view.getMapXForPoint(points.get(0).getLongitude());
|
||||||
|
|
Loading…
Reference in a new issue