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();
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;
}

View file

@ -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();
}

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.
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);

View file

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

View file

@ -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;

View file

@ -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();

View file

@ -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<RecyclerView.ViewHolder> {
@ -29,10 +24,10 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private UpdateLocationViewCache cache;
public FavouritesAdapter(OsmandApplication app, Activity a, List<FavouritePoint> FavouritePoints) {
public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) {
this.app = app;
this.favouritePoints = FavouritePoints;
cache = app.getUIUtilities().getUpdateLocationViewCache(a);
cache = app.getUIUtilities().getUpdateLocationViewCache();
}
@Override

View file

@ -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()

View file

@ -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) {

View file

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

View file

@ -44,7 +44,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
setHasStableIds(true);
this.mapActivity = mapActivity;
uiUtilities = mapActivity.getMyApplication().getUIUtilities();
updateLocationViewCache = uiUtilities.getUpdateLocationViewCache(mapActivity);
updateLocationViewCache = uiUtilities.getUpdateLocationViewCache();
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
night = !mapActivity.getMyApplication().getSettings().isLightContent();
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) {
this.mapActivity = mapActivity;
app = mapActivity.getMyApplication();
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(mapActivity);
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
night = !mapActivity.getMyApplication().getSettings().isLightContent();
updateShowDirectionMarkers();
createDisplayGroups();

View file

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

View file

@ -71,7 +71,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
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) {

View file

@ -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);