diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index be75cb4f6b..633b6e8cc4 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -9,7 +9,6 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.MapControlsLayer; @@ -43,6 +42,7 @@ public class WaypointDialogHelper { public final static boolean OVERLAP_LAYOUT = true; // only true is supported private View closePointDialog; + private List many = new ArrayList(); public WaypointDialogHelper(MapActivity mapActivity) { @@ -53,11 +53,10 @@ public class WaypointDialogHelper { } public void updateDialog() { - List vlp = waypointHelper.getWaypoints(WaypointHelper.FAVORITES); - if (vlp.isEmpty()) { + final LocationPointWrapper point = waypointHelper.getMostImportantLocationPoint(many); + if (point == null) { removeDialog(); } else { - final LocationPointWrapper point = vlp.get(0); boolean created = false; if (closePointDialog == null) { created = true; @@ -66,7 +65,7 @@ public class WaypointDialogHelper { } updatePointInfoView(app, mapActivity, closePointDialog, point); View all = closePointDialog.findViewById(R.id.all_points); - all.setVisibility(vlp.size() <= 1 ? View.GONE : View.VISIBLE); + all.setVisibility(many.size() <= 1 ? View.GONE : View.VISIBLE); if (created) { closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black)); ((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE); diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 984371fbd1..811c0a9e33 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -89,41 +89,37 @@ public class WaypointHelper { } } - public LocationPointWrapper getMostImportantLocationPoint(LocationPoint p) { + public LocationPointWrapper getMostImportantLocationPoint(List list ) { //Location lastProjection = app.getRoutingHelper().getLastProjection(); + if(list != null) { + list.clear(); + } + LocationPointWrapper found = null; for (int type = 0; type < locationPoints.size(); type++) { if(type == ALARMS || type == TARGETS) { continue; } int kIterator = pointsProgress.get(type); + List lp = locationPoints.get(type); + while(kIterator < lp.size()) { + LocationPointWrapper lwp = lp.get(kIterator); + if(lp.get(kIterator).routeIndex < route.getCurrentRoute()) { + // skip + } else { + if(route.getDistanceToPoint(lwp.routeIndex) <= LONG_ANNOUNCE_RADIUS ) { + if(found == null || found.routeIndex < lwp.routeIndex) { + found = lwp; + if(list != null) { + list.add(lwp); + } + } + } + break; + } + kIterator++; + } } - if(ALARMS < pointsProgress.size()) { - -// List lp = locationPoints.get(ALARMS); -// while(kIterator < lp.size()) { -// LocationPointWrapper lwp = lp.get(kIterator); -// if(lp.get(kIterator).routeIndex < route.getCurrentRoute()) { -// // skip -// } else if(route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS ){ -// break; -// } else { -// AlarmInfo inf = (AlarmInfo) lwp.point; -// int d = route.getDistanceToPoint(lwp.routeIndex); -// if(d > 250){ -// break; -// } -// float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0; -// float time = speed > 0 ? d / speed : Integer.MAX_VALUE; -// int vl = inf.updateDistanceAndGetPriority(time, d); -// if(vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)){ -// mostImportant = inf; -// value = vl; -// } -// } -// kIterator++; -// } - } - return null; + return found; } public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) {