From 56e2912b39e206db5bdc486ebc3ef2713d19fb8d Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 16 Feb 2018 16:17:22 +0200 Subject: [PATCH] refactored const --- .../net/osmand/plus/mapcontextmenu/MapContextMenu.java | 1 + .../plus/mapcontextmenu/MapContextMenuFragment.java | 4 ++-- .../net/osmand/plus/mapcontextmenu/MenuBuilder.java | 9 +-------- .../net/osmand/plus/mapcontextmenu/MenuController.java | 4 ++-- .../controllers/TransportStopController.java | 10 ++-------- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index c0b29a96fa..280e293b60 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -798,6 +798,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } return null; } + public List getNearbyTransportStopRoutes() { if (menuController != null) { return menuController.getNearbyTransportStopRoutes(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b4fca9dd0f..67cb56d2e3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -60,7 +60,7 @@ import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.controls.HorizontalSwipeConfirm; import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.util.Algorithms; -import java.util.ArrayList; + import java.util.List; import static android.util.TypedValue.COMPLEX_UNIT_DIP; @@ -507,7 +507,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } if (nearbyTransportStopRoutes != null && nearbyTransportStopRoutes.size() > 0) { String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " " - + OsmAndFormatter.getFormattedDistance(TransportStopController.RADIUS, getMyApplication()); + + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_IN_METERS, getMyApplication()); nearbRoutesWithinTv.setText(nearInDistance); nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes)); nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index aed0c1f031..0ed25e0104 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -31,23 +31,17 @@ import android.widget.Toast; import net.osmand.AndroidUtils; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; -import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.osm.PoiCategory; -import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard; import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder; @@ -56,7 +50,6 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.transport.TransportStopRoute; -import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.widgets.TextViewEx; @@ -317,7 +310,7 @@ public class MenuBuilder { CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true); if (collapsableView != null) { - String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.RADIUS,app); + String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_IN_METERS,app); buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView, false, 0, false, null, true); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index a27acf8e83..eca93b6ba9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -523,13 +523,13 @@ public abstract class MenuController extends BaseMenuController implements Colla return null; } - private List getSubTransportStopRoutes(boolean isNearby) { + private List getSubTransportStopRoutes(boolean nearby) { List allRoutes = getTransportStopRoutes(); if (allRoutes != null) { List res = new ArrayList<>(); for (TransportStopRoute route : allRoutes) { boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName()); - if (isNearby) { + if (nearby) { if (isCurrentRouteNearby) { res.add(route); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 72960cae93..9b80ccd9d6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -1,9 +1,5 @@ package net.osmand.plus.mapcontextmenu.controllers; -import android.view.View; -import android.view.View.OnClickListener; - -import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.TransportRoute; @@ -11,12 +7,10 @@ import net.osmand.data.TransportStop; import net.osmand.plus.R; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.transport.TransportStopType; -import net.osmand.plus.views.TransportStopsLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -28,7 +22,7 @@ import java.util.List; public class TransportStopController extends MenuController { - public static final int RADIUS =150; + public static final int SHOW_STOPS_RADIUS_IN_METERS = 150; private TransportStop transportStop; private List routes = new ArrayList<>(); @@ -103,7 +97,7 @@ public class TransportStopController extends MenuController { addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0); } ArrayList ls = new ArrayList<>(); - QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), RADIUS); + QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), SHOW_STOPS_RADIUS_IN_METERS); t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null); for(TransportStop tstop : ls) { if(tstop.getId().longValue() != transportStop.getId().longValue() || empty) {