diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 4f04e72d30..de1d8abc25 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -99,9 +99,9 @@ public class UiUtilities { } - public UpdateLocationViewCache getUpdateLocationViewCache(Activity a){ + public UpdateLocationViewCache getUpdateLocationViewCache(){ UpdateLocationViewCache uvc = new UpdateLocationViewCache(); - uvc.screenOrientation = getScreenOrientation(a); + uvc.screenOrientation = getScreenOrientation(); return uvc; } @@ -172,7 +172,7 @@ public class UiUtilities { if (fromLoc == null || h == null || toLoc == null) { dd.setAngle(0); } else { - float orientation = (cache == null ? 0 : -cache.screenOrientation) * 90; + float orientation = (cache == null ? 0 : -cache.screenOrientation) ; dd.setAngle(mes[1] - h + 180 + orientation); } if (newImage) { @@ -199,8 +199,8 @@ public class UiUtilities { } } - public static int getScreenOrientation(Activity a) { - int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); + public int getScreenOrientation() { + int screenOrientation = ((WindowManager) app.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); switch (screenOrientation) { case ORIENTATION_0: // Device default (normally portrait) screenOrientation = 0; @@ -216,7 +216,7 @@ public class UiUtilities { break; } //Looks like screenOrientation correction must not be applied for devices without compass? - Sensor compass = ((SensorManager) a.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); + Sensor compass = ((SensorManager) app.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); if (compass == null) { screenOrientation = 0; } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java index 6f1b283c78..27fc4c3907 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java @@ -166,7 +166,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA this.activity = activity; this.app = ((OsmandApplication) activity.getApplication()); this.shouldShowMenuButton = shouldShowMenuButton; - cache = app.getUIUtilities().getUpdateLocationViewCache(activity); + cache = app.getUIUtilities().getUpdateLocationViewCache(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java index 83191ef1da..e3258b7c68 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java @@ -124,7 +124,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA //Hardy: onResume() code is needed so that search origin is properly reflected in tab contents when origin has been changed on one tab, then tab is changed to another one. location = null; FragmentActivity activity = getActivity(); - updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getActivity()); + updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(); Intent intent = activity.getIntent(); if (intent != null) { double lat = intent.getDoubleExtra(SEARCH_LAT, 0); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index ea8baa460b..22e38384a9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -721,7 +721,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa AmenityAdapter(List list) { super(SearchPOIActivity.this, R.layout.searchpoi_list, list); - updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(SearchPOIActivity.this); + updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(); originalAmenityList = new ArrayList(list); this.setNotifyOnChange(false); } @@ -732,7 +732,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa public void setNewModel(List amenityList) { setNotifyOnChange(false); - updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(SearchPOIActivity.this); + updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(); originalAmenityList = new ArrayList(amenityList); clear(); for (Amenity obj : amenityList) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java index 0ff8965496..4387bb4cfa 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashLocationFragment.java @@ -55,7 +55,7 @@ public abstract class DashLocationFragment extends DashBaseFragment { return; } UiUtilities ic = getMyApplication().getUIUtilities(); - UpdateLocationViewCache cache = ic.getUpdateLocationViewCache(getActivity()); + UpdateLocationViewCache cache = ic.getUpdateLocationViewCache(); for (DashLocationView lv : distances) { cache.arrowResId = lv.arrowResId; cache.paintTxt = lv.paint; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 243913f2c6..91e8ce13b5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -142,7 +142,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo processScreenHeight(container); menu = getMapActivity().getContextMenu(); - updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getMapActivity()); + updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(); markerPaddingPx = dpToPx(MARKER_PADDING_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); @@ -1173,7 +1173,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo dismissMenu(); return; } - updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getMapActivity()); + updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(); getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false); wasDrawerDisabled = getMapActivity().isDrawerDisabled(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesAdapter.java index 98cfe4b180..83460e028c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesAdapter.java @@ -1,5 +1,12 @@ package net.osmand.plus.mapcontextmenu.other; +import java.util.List; + +import net.osmand.data.FavouritePoint; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities.UpdateLocationViewCache; +import net.osmand.plus.base.FavoriteImageDrawable; import android.app.Activity; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -7,18 +14,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import net.osmand.data.FavouritePoint; -import net.osmand.data.LatLon; -import net.osmand.plus.UiUtilities; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.UiUtilities.UpdateLocationViewCache; -import net.osmand.plus.base.FavoriteImageDrawable; -import net.osmand.plus.dashboard.DashLocationFragment; -import net.osmand.util.MapUtils; - -import java.util.List; public class FavouritesAdapter extends RecyclerView.Adapter { @@ -29,10 +24,10 @@ public class FavouritesAdapter extends RecyclerView.Adapter FavouritePoints) { + public FavouritesAdapter(OsmandApplication app, List FavouritePoints) { this.app = app; this.favouritePoints = FavouritePoints; - cache = app.getUIUtilities().getUpdateLocationViewCache(a); + cache = app.getUIUtilities().getUpdateLocationViewCache(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java index 07cfe2bc34..3c014bb30e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java @@ -64,7 +64,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - adapter = new FavouritesAdapter(getMyApplication(), getActivity(), favouritePoints); + adapter = new FavouritesAdapter(getMyApplication(), favouritePoints); sortFavourites(); final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1]; title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder() diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index b614901b98..20d127a2ca 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -63,7 +63,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); onClickListener = routeInfoMenu.getOnMarkerSelectListener(); - screenOrientation = app.getUIUtilities().getScreenOrientation(mapActivity); + screenOrientation = app.getUIUtilities().getScreenOrientation(); MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities(); if (trackingUtils != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/CoordinateInputAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/CoordinateInputAdapter.java index b2508dcff9..66286e9065 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/CoordinateInputAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/CoordinateInputAdapter.java @@ -30,7 +30,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter mapMarkers) { this.mapActivity = mapActivity; iconsCache = mapActivity.getMyApplication().getUIUtilities(); - updateViewCache = iconsCache.getUpdateLocationViewCache(mapActivity); + updateViewCache = iconsCache.getUpdateLocationViewCache(); this.mapMarkers = mapMarkers; nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 30b2d76eb2..7c554c4c4e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -44,7 +44,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter { this.activity = activity; dp56 = AndroidUtils.dpToPx(app, 56f); dp1 = AndroidUtils.dpToPx(app, 1f); - updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(activity); + updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(); } public void setAccessibilityAssistant(AccessibilityAssistant accessibilityAssistant) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 0814cc49dd..d09e8e0b97 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -60,7 +60,7 @@ public class MapMarkersWidgetsFactory { public MapMarkersWidgetsFactory(final MapActivity map) { this.map = map; helper = map.getMyApplication().getMapMarkersHelper(); - screenOrientation = map.getMyApplication().getUIUtilities().getScreenOrientation(map); + screenOrientation = map.getMyApplication().getUIUtilities().getScreenOrientation(); portraitMode = AndroidUiHelper.isOrientationPortrait(map); addressTopBar = map.findViewById(R.id.map_top_bar);