From 1ca57cdea2a994b85718db2ef3cc70bd31efc666 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 21 Dec 2014 23:26:44 +0100 Subject: [PATCH] Fix waypoints --- .../plus/helpers/WaypointDialogHelper.java | 2 +- .../osmand/plus/helpers/WaypointHelper.java | 88 +++---------------- 2 files changed, 15 insertions(+), 75 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 5c22158e7d..fcb028834e 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -145,7 +145,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { } }); TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); - ((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(ctx)); + ((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(ctx, app)); int dist = -1; if (!wh.isRouteCalculated()) { if (ctx instanceof MapActivity) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index bf51a112af..aad67af126 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -657,66 +657,9 @@ public class WaypointHelper { } - public int getDrawableId(Context uiCtx) { - if(type == POI) { - Amenity amenity = ((AmenityLocationPoint) point).a; - StringBuilder tag = new StringBuilder(); - StringBuilder value = new StringBuilder(); - MapRenderingTypes.getDefault().getAmenityTagValue(amenity.getType(), amenity.getSubType(), - tag, value); - if(RenderingIcons.containsBigIcon(tag + "_" + value)) { - return RenderingIcons.getBigIconResourceId(tag + "_" + value); - } else if(RenderingIcons.containsBigIcon(value.toString())) { - return RenderingIcons.getBigIconResourceId(value.toString()); - } - return 0; - } else if(type == TARGETS) { - return !((TargetPoint)point).intermediate? R.drawable.list_destination: - R.drawable.list_intermediate; - } else if(type == FAVORITES || type == WAYPOINTS) { - //return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor()); - return 0; - } else if(type == ALARMS) { - //assign alarm list icons manually for now - //attention, some list icons are only temporary test icons, not pixel perfect yet. - if(((AlarmInfo) point).getType().toString() == "SPEED_CAMERA") { - return R.drawable.mx_highway_speed_camera; - } else if(((AlarmInfo) point).getType().toString() == "BORDER_CONTROL") { - return R.drawable.mx_barrier_border_control; - } else if(((AlarmInfo) point).getType().toString() == "RAILWAY") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return R.drawable.list_warnings_railways_us; - //} else { - return R.drawable.list_warnings_railways; - //} - } else if(((AlarmInfo) point).getType().toString() == "TRAFFIC_CALMING") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return R.drawable.list_traffic_calming_us; - //} else { - return R.drawable.list_traffic_calming; - //} - } else if(((AlarmInfo) point).getType().toString() == "TOLL_BOOTH") { - return R.drawable.mx_barrier_toll_booth; - } else if(((AlarmInfo) point).getType().toString() == "STOP") { - return R.drawable.list_stop; - } else if(((AlarmInfo) point).getType().toString() == "PEDESTRIAN") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return R.drawable.list_warnings_pedestrian_us; - //} else { - return R.drawable.list_warnings_pedestrian; - //} - } else { - return 0; - } - } else { - return 0; - } - } + - public Drawable getDrawable(Context uiCtx) { + public Drawable getDrawable(Context uiCtx, OsmandApplication app) { if(type == POI) { Amenity amenity = ((AmenityLocationPoint) point).a; StringBuilder tag = new StringBuilder(); @@ -743,30 +686,27 @@ public class WaypointHelper { } else if(((AlarmInfo) point).getType().toString() == "BORDER_CONTROL") { return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control); } else if(((AlarmInfo) point).getType().toString() == "RAILWAY") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us); - //} else { + if(app.getSettings().DRIVING_REGION.get().americanSigns){ + return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us); + } else { return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways); - //} + } } else if(((AlarmInfo) point).getType().toString() == "TRAFFIC_CALMING") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return uiCtx.getResources().getDrawable(R.drawable.list_traffic_calming_us); - //} else { + if(app.getSettings().DRIVING_REGION.get().americanSigns){ return uiCtx.getResources().getDrawable(R.drawable.list_traffic_calming); - //} + } else { + return uiCtx.getResources().getDrawable(R.drawable.list_traffic_calming); + } } else if(((AlarmInfo) point).getType().toString() == "TOLL_BOOTH") { return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_toll_booth); } else if(((AlarmInfo) point).getType().toString() == "STOP") { return uiCtx.getResources().getDrawable(R.drawable.list_stop); } else if(((AlarmInfo) point).getType().toString() == "PEDESTRIAN") { - //this produces error: non-static variable app cannot be referenced from a static context - //if(app.getSettings.DRIVING_REGION.get().americanSigns){ - // return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us); - //} else { + if(app.getSettings().DRIVING_REGION.get().americanSigns){ + return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us); + } else { return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian); - //} + } } else { return null; }