Refactor points

This commit is contained in:
Victor Shcherb 2014-08-19 10:53:23 +02:00
parent 4e848859d7
commit 7d1f4c38b6
2 changed files with 28 additions and 33 deletions

View file

@ -9,7 +9,6 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
@ -43,6 +42,7 @@ public class WaypointDialogHelper {
public final static boolean OVERLAP_LAYOUT = true; // only true is supported public final static boolean OVERLAP_LAYOUT = true; // only true is supported
private View closePointDialog; private View closePointDialog;
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
public WaypointDialogHelper(MapActivity mapActivity) { public WaypointDialogHelper(MapActivity mapActivity) {
@ -53,11 +53,10 @@ public class WaypointDialogHelper {
} }
public void updateDialog() { public void updateDialog() {
List<LocationPointWrapper> vlp = waypointHelper.getWaypoints(WaypointHelper.FAVORITES); final LocationPointWrapper point = waypointHelper.getMostImportantLocationPoint(many);
if (vlp.isEmpty()) { if (point == null) {
removeDialog(); removeDialog();
} else { } else {
final LocationPointWrapper point = vlp.get(0);
boolean created = false; boolean created = false;
if (closePointDialog == null) { if (closePointDialog == null) {
created = true; created = true;
@ -66,7 +65,7 @@ public class WaypointDialogHelper {
} }
updatePointInfoView(app, mapActivity, closePointDialog, point); updatePointInfoView(app, mapActivity, closePointDialog, point);
View all = closePointDialog.findViewById(R.id.all_points); 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) { if (created) {
closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black)); closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black));
((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE); ((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);

View file

@ -89,41 +89,37 @@ public class WaypointHelper {
} }
} }
public LocationPointWrapper getMostImportantLocationPoint(LocationPoint p) { public LocationPointWrapper getMostImportantLocationPoint(List<LocationPointWrapper> list ) {
//Location lastProjection = app.getRoutingHelper().getLastProjection(); //Location lastProjection = app.getRoutingHelper().getLastProjection();
if(list != null) {
list.clear();
}
LocationPointWrapper found = null;
for (int type = 0; type < locationPoints.size(); type++) { for (int type = 0; type < locationPoints.size(); type++) {
if(type == ALARMS || type == TARGETS) { if(type == ALARMS || type == TARGETS) {
continue; continue;
} }
int kIterator = pointsProgress.get(type); int kIterator = pointsProgress.get(type);
List<LocationPointWrapper> 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);
} }
if(ALARMS < pointsProgress.size()) {
// List<LocationPointWrapper> 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; }
break;
}
kIterator++;
}
}
return found;
} }
public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) { public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) {