Refactor points
This commit is contained in:
parent
4e848859d7
commit
7d1f4c38b6
2 changed files with 28 additions and 33 deletions
|
@ -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<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
|
||||
|
||||
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||
|
@ -53,11 +53,10 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
public void updateDialog() {
|
||||
List<LocationPointWrapper> 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);
|
||||
|
|
|
@ -89,41 +89,37 @@ public class WaypointHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public LocationPointWrapper getMostImportantLocationPoint(LocationPoint p) {
|
||||
public LocationPointWrapper getMostImportantLocationPoint(List<LocationPointWrapper> 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<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
kIterator++;
|
||||
}
|
||||
}
|
||||
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;
|
||||
return found;
|
||||
}
|
||||
|
||||
public AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras) {
|
||||
|
|
Loading…
Reference in a new issue