Remove unnecessary method

This commit is contained in:
Victor Shcherb 2018-05-24 10:25:06 +02:00
parent f6859d5ed0
commit 83915a44ab
15 changed files with 30 additions and 35 deletions

View file

@ -99,9 +99,9 @@ public class UiUtilities {
} }
public UpdateLocationViewCache getUpdateLocationViewCache(Activity a){ public UpdateLocationViewCache getUpdateLocationViewCache(){
UpdateLocationViewCache uvc = new UpdateLocationViewCache(); UpdateLocationViewCache uvc = new UpdateLocationViewCache();
uvc.screenOrientation = getScreenOrientation(a); uvc.screenOrientation = getScreenOrientation();
return uvc; return uvc;
} }
@ -172,7 +172,7 @@ public class UiUtilities {
if (fromLoc == null || h == null || toLoc == null) { if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {
float orientation = (cache == null ? 0 : -cache.screenOrientation) * 90; float orientation = (cache == null ? 0 : -cache.screenOrientation) ;
dd.setAngle(mes[1] - h + 180 + orientation); dd.setAngle(mes[1] - h + 180 + orientation);
} }
if (newImage) { if (newImage) {
@ -199,8 +199,8 @@ public class UiUtilities {
} }
} }
public static int getScreenOrientation(Activity a) { public int getScreenOrientation() {
int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); int screenOrientation = ((WindowManager) app.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
switch (screenOrientation) { switch (screenOrientation) {
case ORIENTATION_0: // Device default (normally portrait) case ORIENTATION_0: // Device default (normally portrait)
screenOrientation = 0; screenOrientation = 0;
@ -216,7 +216,7 @@ public class UiUtilities {
break; break;
} }
//Looks like screenOrientation correction must not be applied for devices without compass? //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) { if (compass == null) {
screenOrientation = 0; screenOrientation = 0;
} }

View file

@ -166,7 +166,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
this.activity = activity; this.activity = activity;
this.app = ((OsmandApplication) activity.getApplication()); this.app = ((OsmandApplication) activity.getApplication());
this.shouldShowMenuButton = shouldShowMenuButton; this.shouldShowMenuButton = shouldShowMenuButton;
cache = app.getUIUtilities().getUpdateLocationViewCache(activity); cache = app.getUIUtilities().getUpdateLocationViewCache();
} }

View file

@ -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. //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; location = null;
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getActivity()); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
Intent intent = activity.getIntent(); Intent intent = activity.getIntent();
if (intent != null) { if (intent != null) {
double lat = intent.getDoubleExtra(SEARCH_LAT, 0); double lat = intent.getDoubleExtra(SEARCH_LAT, 0);

View file

@ -721,7 +721,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
AmenityAdapter(List<Amenity> list) { AmenityAdapter(List<Amenity> list) {
super(SearchPOIActivity.this, R.layout.searchpoi_list, list); super(SearchPOIActivity.this, R.layout.searchpoi_list, list);
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(SearchPOIActivity.this); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
originalAmenityList = new ArrayList<Amenity>(list); originalAmenityList = new ArrayList<Amenity>(list);
this.setNotifyOnChange(false); this.setNotifyOnChange(false);
} }
@ -732,7 +732,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
public void setNewModel(List<Amenity> amenityList) { public void setNewModel(List<Amenity> amenityList) {
setNotifyOnChange(false); setNotifyOnChange(false);
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(SearchPOIActivity.this); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
originalAmenityList = new ArrayList<Amenity>(amenityList); originalAmenityList = new ArrayList<Amenity>(amenityList);
clear(); clear();
for (Amenity obj : amenityList) { for (Amenity obj : amenityList) {

View file

@ -55,7 +55,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
return; return;
} }
UiUtilities ic = getMyApplication().getUIUtilities(); UiUtilities ic = getMyApplication().getUIUtilities();
UpdateLocationViewCache cache = ic.getUpdateLocationViewCache(getActivity()); UpdateLocationViewCache cache = ic.getUpdateLocationViewCache();
for (DashLocationView lv : distances) { for (DashLocationView lv : distances) {
cache.arrowResId = lv.arrowResId; cache.arrowResId = lv.arrowResId;
cache.paintTxt = lv.paint; cache.paintTxt = lv.paint;

View file

@ -142,7 +142,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
processScreenHeight(container); processScreenHeight(container);
menu = getMapActivity().getContextMenu(); menu = getMapActivity().getContextMenu();
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getMapActivity()); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
markerPaddingPx = dpToPx(MARKER_PADDING_DP); markerPaddingPx = dpToPx(MARKER_PADDING_DP);
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
@ -1173,7 +1173,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
dismissMenu(); dismissMenu();
return; return;
} }
updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache(getMapActivity()); updateLocationViewCache = getMyApplication().getUIUtilities().getUpdateLocationViewCache();
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false); getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
wasDrawerDisabled = getMapActivity().isDrawerDisabled(); wasDrawerDisabled = getMapActivity().isDrawerDisabled();

View file

@ -1,5 +1,12 @@
package net.osmand.plus.mapcontextmenu.other; 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.app.Activity;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -7,18 +14,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; 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<RecyclerView.ViewHolder> { public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -29,10 +24,10 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private UpdateLocationViewCache cache; private UpdateLocationViewCache cache;
public FavouritesAdapter(OsmandApplication app, Activity a, List<FavouritePoint> FavouritePoints) { public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) {
this.app = app; this.app = app;
this.favouritePoints = FavouritePoints; this.favouritePoints = FavouritePoints;
cache = app.getUIUtilities().getUpdateLocationViewCache(a); cache = app.getUIUtilities().getUpdateLocationViewCache();
} }
@Override @Override

View file

@ -64,7 +64,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes), recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.recyclerview, null); R.layout.recyclerview, null);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
adapter = new FavouritesAdapter(getMyApplication(), getActivity(), favouritePoints); adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
sortFavourites(); sortFavourites();
final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1]; final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1];
title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder() title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()

View file

@ -63,7 +63,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
onClickListener = routeInfoMenu.getOnMarkerSelectListener(); onClickListener = routeInfoMenu.getOnMarkerSelectListener();
screenOrientation = app.getUIUtilities().getScreenOrientation(mapActivity); screenOrientation = app.getUIUtilities().getScreenOrientation();
MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities(); MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
if (trackingUtils != null) { if (trackingUtils != null) {

View file

@ -30,7 +30,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
public CoordinateInputAdapter(MapActivity mapActivity, List<MapMarker> mapMarkers) { public CoordinateInputAdapter(MapActivity mapActivity, List<MapMarker> mapMarkers) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
iconsCache = mapActivity.getMyApplication().getUIUtilities(); iconsCache = mapActivity.getMyApplication().getUIUtilities();
updateViewCache = iconsCache.getUpdateLocationViewCache(mapActivity); updateViewCache = iconsCache.getUpdateLocationViewCache();
this.mapMarkers = mapMarkers; this.mapMarkers = mapMarkers;
nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent(); nightTheme = !mapActivity.getMyApplication().getSettings().isLightContent();
} }

View file

@ -44,7 +44,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
setHasStableIds(true); setHasStableIds(true);
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
uiUtilities = mapActivity.getMyApplication().getUIUtilities(); uiUtilities = mapActivity.getMyApplication().getUIUtilities();
updateLocationViewCache = uiUtilities.getUpdateLocationViewCache(mapActivity); updateLocationViewCache = uiUtilities.getUpdateLocationViewCache();
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers(); markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
night = !mapActivity.getMyApplication().getSettings().isLightContent(); night = !mapActivity.getMyApplication().getSettings().isLightContent();
showDirectionEnabled = mapActivity.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get(); showDirectionEnabled = mapActivity.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get();

View file

@ -74,7 +74,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
public MapMarkersGroupsAdapter(MapActivity mapActivity) { public MapMarkersGroupsAdapter(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
app = mapActivity.getMyApplication(); app = mapActivity.getMyApplication();
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(mapActivity); updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
night = !mapActivity.getMyApplication().getSettings().isLightContent(); night = !mapActivity.getMyApplication().getSettings().isLightContent();
updateShowDirectionMarkers(); updateShowDirectionMarkers();
createDisplayGroups(); createDisplayGroups();

View file

@ -116,7 +116,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
dismiss(); dismiss();
} }
}); });
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(getActivity()); updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
myLocation = app.getLocationProvider().getLastKnownLocation(); myLocation = app.getLocationProvider().getLastKnownLocation();
currentFormat = app.getSettings().COORDINATES_FORMAT.get(); currentFormat = app.getSettings().COORDINATES_FORMAT.get();

View file

@ -71,7 +71,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
this.activity = activity; this.activity = activity;
dp56 = AndroidUtils.dpToPx(app, 56f); dp56 = AndroidUtils.dpToPx(app, 56f);
dp1 = AndroidUtils.dpToPx(app, 1f); dp1 = AndroidUtils.dpToPx(app, 1f);
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(activity); updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
} }
public void setAccessibilityAssistant(AccessibilityAssistant accessibilityAssistant) { public void setAccessibilityAssistant(AccessibilityAssistant accessibilityAssistant) {

View file

@ -60,7 +60,7 @@ public class MapMarkersWidgetsFactory {
public MapMarkersWidgetsFactory(final MapActivity map) { public MapMarkersWidgetsFactory(final MapActivity map) {
this.map = map; this.map = map;
helper = map.getMyApplication().getMapMarkersHelper(); helper = map.getMyApplication().getMapMarkersHelper();
screenOrientation = map.getMyApplication().getUIUtilities().getScreenOrientation(map); screenOrientation = map.getMyApplication().getUIUtilities().getScreenOrientation();
portraitMode = AndroidUiHelper.isOrientationPortrait(map); portraitMode = AndroidUiHelper.isOrientationPortrait(map);
addressTopBar = map.findViewById(R.id.map_top_bar); addressTopBar = map.findViewById(R.id.map_top_bar);