update route points activity

This commit is contained in:
Victor Shcherb 2014-06-19 15:05:32 +02:00
parent 5c4b218c90
commit b0afbeb678
4 changed files with 42 additions and 4 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gpx_color_point">#cd2c33</color>
<color name="gpx_speed">#c79c00</color>
<color name="gpx_altitude_desc">#32CD32</color>
<color name="gpx_altitude_asc">#EE3232</color>

View file

@ -6,6 +6,7 @@ import java.util.List;
import net.osmand.CallbackWithObject;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
@ -71,7 +72,10 @@ public class RoutePointsActivity extends OsmandListActivity {
GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
@Override
public boolean processResult(GPXUtilities.GPXFile[] result) {
plugin.setCurrentRoute(result[0]);
final GPXFile gpx = result[0];
app.getSelectedGpxHelper().clearAllGpxFileToShow();
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
plugin.setCurrentRoute(gpx);
SelectedRouteGpxFile sgpx = plugin.getCurrentRoute();
sgpx.naviateToNextPoint();
prepareView();
@ -80,6 +84,14 @@ public class RoutePointsActivity extends OsmandListActivity {
});
}
@Override
protected void onResume() {
super.onResume();
if(plugin.getCurrentRoute() != null) {
plugin.getCurrentRoute().updateCurrentTargetPoint();
}
}
private void prepareView() {
TextView gpxName = (TextView) findViewById(R.id.gpx_name);

View file

@ -333,5 +333,20 @@ public class RoutePointsPlugin extends OsmandPlugin {
app.getTargetPointsHelper().navigateToPoint(rp.getPoint(), true, -1, rp.getName());
}
public void updateCurrentTargetPoint() {
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
String locName = targetPointsHelper.getPointNavigateDescription();
for(int i = 0; i < currentPoints.size(); i++) {
RoutePoint rtp = currentPoints.get(i);
rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(rtp.getName());
if(rtp.isNextNavigate) {
locName = null;
}
}
sortPoints();
}
}
}

View file

@ -97,7 +97,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
int clr = getColor(settings);
cache.clear();
int pointColor = view.getResources().getColor(R.color.gpx_track);
int defPointColor = view.getResources().getColor(R.color.gpx_color_point);
int visitedColor = view.getContext().getResources().getColor(R.color.color_ok);
if (!selectedGPXFiles.isEmpty()) {
for (SelectedGpxFile g : selectedGPXFiles) {
List<List<WptPt>> points = g.getPointsToDisplay();
@ -111,9 +112,18 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (SelectedGpxFile g : selectedGPXFiles) {
List<WptPt> pts = g.getGpxFile().points;
int fcolor = g.getColor() == 0 ? pointColor : g.getColor();
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), fcolor);
if(pts.isEmpty() & !g.getGpxFile().routes.isEmpty()) {
pts = g.getGpxFile().routes.get(0).points;
}
int fcolor = g.getColor() == 0 ? defPointColor : g.getColor();
for (WptPt o : pts) {
int pointColor = o.getColor(fcolor);
String visited = o.getExtensionsToRead().get("VISITED_KEY");
if(visited != null && !visited.equals("0")) {
pointColor = visitedColor;
}
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor);
if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top
&& o.lon >= latLonBounds.left && o.lon <= latLonBounds.right) {
cache.add(o);