This commit is contained in:
Victor Shcherb 2018-05-23 22:56:35 +02:00
parent 9d75efd61d
commit d1de3a8dd1
15 changed files with 91 additions and 78 deletions

View file

@ -238,7 +238,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false)); icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText, DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity); favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app);
name.setText(getName(favorite)); name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item); final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);

View file

@ -242,7 +242,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
TextView distanceText = (TextView) row.findViewById(R.id.distance); TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView direction = (ImageView) row.findViewById(R.id.direction); ImageView direction = (ImageView) row.findViewById(R.id.direction);
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText, DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
historyEntry.getLat(), historyEntry.getLon(), screenOrientation, getMyApplication(), getActivity()); historyEntry.getLat(), historyEntry.getLon(), screenOrientation, getMyApplication());
ImageButton options = (ImageButton) row.findViewById(R.id.options); ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);

View file

@ -785,7 +785,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
if (dd instanceof DirectionDrawable) { if (dd instanceof DirectionDrawable) {
draw = (DirectionDrawable) dd; draw = (DirectionDrawable) dd;
} else { } else {
draw = new DirectionDrawable(SearchPOIActivity.this, 24, 24, draw = new DirectionDrawable(getMyApplication(), 24, 24,
R.drawable.ic_direction_arrow, R.color.color_distance); R.drawable.ic_direction_arrow, R.color.color_distance);
direction.setImageDrawable(draw); direction.setImageDrawable(draw);
} }

View file

@ -32,7 +32,6 @@ public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_180 = 2; private static final int ORIENTATION_180 = 2;
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
private int screenOrientation; private int screenOrientation;
protected LatLon lastUpdatedLocation;
public static class DashLocationView { public static class DashLocationView {
public ImageView arrow; public ImageView arrow;
@ -98,50 +97,61 @@ public abstract class DashLocationFragment extends DashBaseFragment {
float head = d.getHeading(); float head = d.getHeading();
float mapRotation = d.getMapRotation(); float mapRotation = d.getMapRotation();
LatLon mw = d.getMapViewLocation(); LatLon mw = d.getMapViewLocation();
Location l = d.getMyLocation(); boolean useCenter = !d.isMapLinkedToLocation();
boolean mapLinked = d.isMapLinkedToLocation() && l != null;
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
boolean useCenter = !mapLinked;
LatLon loc = (useCenter ? mw : myLoc);
float h = useCenter ? -mapRotation : head; float h = useCenter ? -mapRotation : head;
lastUpdatedLocation = loc;
for (DashLocationView lv : distances) { for (DashLocationView lv : distances) {
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation, updateLocationView(useCenter, mw, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
getMyApplication(), getActivity(), lv.paint); getMyApplication(), lv.paint);
} }
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon, ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) { int screenOrientation, OsmandApplication app, Context ctx) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, ctx, true); updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, true);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon, ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) { int screenOrientation, OsmandApplication app) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, ctx, true); updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, true);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc, ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint); updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, paint);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc, ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint); updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, paint);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc, ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
float[] mes = new float[2]; float[] mes = new float[2];
boolean stale = false;
if(!useCenter) {
Location loc = app.getLocationProvider().getLastKnownLocation();
if(loc == null) {
loc = app.getLocationProvider().getLastStaleKnownLocation();
stale = true;
}
if(loc != null) {
fromLoc = new LatLon(loc.getLatitude(), loc.getLongitude());
} else {
fromLoc = null;
}
}
if (fromLoc != null && toLoc != null) { if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes); Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
} }
if (arrow != null) { if (arrow != null) {
boolean newImage = false; boolean newImage = false;
if (arrowResId == 0) { if (arrowResId == 0) {
@ -150,11 +160,18 @@ public abstract class DashLocationFragment extends DashBaseFragment {
DirectionDrawable dd; DirectionDrawable dd;
if(!(arrow.getDrawable() instanceof DirectionDrawable)) { if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true; newImage = true;
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight()); dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
} else { } else {
dd = (DirectionDrawable) arrow.getDrawable(); dd = (DirectionDrawable) arrow.getDrawable();
} }
dd.setImage(arrowResId, imgColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : imgColor); int imgColorSet = imgColor;
if (imgColorSet == 0) {
imgColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance;
if(stale) {
imgColorSet = R.color.icon_color;
}
}
dd.setImage(arrowResId, imgColorSet);
if (fromLoc == null || h == null || toLoc == null) { if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {
@ -168,8 +185,14 @@ public abstract class DashLocationFragment extends DashBaseFragment {
if (txt != null) { if (txt != null) {
if (fromLoc != null && toLoc != null) { if (fromLoc != null && toLoc != null) {
if (paint) { if (paint) {
txt.setTextColor(app.getResources().getColor( int textColorSet = textColor;
textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor)); if(textColorSet == 0) {
textColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance ;
if(stale) {
textColorSet = R.color.icon_color;
}
}
txt.setTextColor(app.getResources().getColor(textColorSet));
} }
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app)); txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else { } else {

View file

@ -149,7 +149,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private ApplicationMode previousAppMode; private ApplicationMode previousAppMode;
private boolean landscape; private boolean landscape;
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>(); private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>();
private net.osmand.Location myLocation;
private LatLon mapViewLocation; private LatLon mapViewLocation;
private float heading; private float heading;
private boolean mapLinkedToLocation; private boolean mapLinkedToLocation;
@ -621,10 +620,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
} }
public net.osmand.Location getMyLocation() {
return myLocation;
}
public LatLon getMapViewLocation() { public LatLon getMapViewLocation() {
return mapViewLocation; return mapViewLocation;
} }
@ -716,7 +711,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
mapViewLocation = mapActivity.getMapLocation(); mapViewLocation = mapActivity.getMapLocation();
mapRotation = mapActivity.getMapRotate(); mapRotation = mapActivity.getMapRotate();
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
mapActivity.getMapViewTrackingUtilities().setDashboard(this); mapActivity.getMapViewTrackingUtilities().setDashboard(this);
mapActivity.disableDrawer(); mapActivity.disableDrawer();
dashboardView.setVisibility(View.VISIBLE); dashboardView.setVisibility(View.VISIBLE);
@ -1218,7 +1212,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
public void updateMyLocation(net.osmand.Location location) { public void updateMyLocation(net.osmand.Location location) {
myLocation = location;
updateLocation(false, true, false); updateLocation(false, true, false);
} }

View file

@ -54,7 +54,7 @@ public class MapMarkerDialogHelper {
DirectionDrawable dd; DirectionDrawable dd;
if (!(arrow.getDrawable() instanceof DirectionDrawable)) { if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true; newImage = true;
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight()); dd = new DirectionDrawable((OsmandApplication) ctx.getApplicationContext(), arrow.getWidth(), arrow.getHeight());
} else { } else {
dd = (DirectionDrawable) arrow.getDrawable(); dd = (DirectionDrawable) arrow.getDrawable();
} }

View file

@ -1,7 +1,5 @@
package net.osmand.plus.mapcontextmenu.other; package net.osmand.plus.mapcontextmenu.other;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -9,7 +7,6 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
@ -24,18 +21,21 @@ import java.util.List;
public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context context;
private final List<FavouritePoint> favouritePoints;
private final List<FavouritePoint> favouritePoints;
private OsmandApplication app;
private IconsCache iconsCache;
private View.OnClickListener listener; private View.OnClickListener listener;
private LatLon location; private LatLon location;
private Float heading; private Float heading;
private boolean useCenter; private boolean useCenter;
private int screenOrientation; private int screenOrientation;
public FavouritesAdapter(Context context, List<FavouritePoint> FavouritePoints) { public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) {
this.app = app;
iconsCache = app.getIconsCache();
this.favouritePoints = FavouritePoints; this.favouritePoints = FavouritePoints;
this.context = context;
} }
@Override @Override
@ -48,8 +48,6 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof FavouritesViewHolder) { if (holder instanceof FavouritesViewHolder) {
OsmandApplication app = (OsmandApplication) ((Activity) context).getApplication();
IconsCache iconsCache = app.getIconsCache();
FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder; FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder;
FavouritePoint favouritePoint = getItem(position); FavouritePoint favouritePoint = getItem(position);
favouritesViewHolder.title.setText(favouritePoint.getName()); favouritesViewHolder.title.setText(favouritePoint.getName());
@ -58,17 +56,16 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else { } else {
favouritesViewHolder.description.setText(favouritePoint.getCategory()); favouritesViewHolder.description.setText(favouritePoint.getCategory());
} }
Location myloc = app.getLocationProvider().getLastKnownLocation(); favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(context, favouritePoint.getColor(), false)); if (location == null) {
if (myloc == null) {
return; return;
} }
float dist = (float) MapUtils.getDistance(favouritePoint.getLatitude(), favouritePoint.getLongitude(), myloc.getLatitude(), myloc.getLongitude()); float dist = (float) MapUtils.getDistance(favouritePoint.getLatitude(), favouritePoint.getLongitude(), location.getLatitude(), location.getLongitude());
favouritesViewHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app)); favouritesViewHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app));
favouritesViewHolder.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow)); favouritesViewHolder.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow));
DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage, DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage,
favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(), favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(),
screenOrientation, app, context); screenOrientation, app);
} }
} }

View file

@ -66,11 +66,16 @@ 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()));
location = getMyApplication().getLocationProvider().getLastKnownLocation(); location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
if (location != null) { if (location != null) {
latLon = new LatLon(location.getLatitude(), location.getLongitude()); latLon = new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(false);
} else {
latLon = ((MapActivity) getActivity()).getMapLocation();
adapter.setUseCenter(true);
} }
adapter = new FavouritesAdapter(getContext(), favouritePoints); adapter.setLocation(latLon);
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()
@ -212,14 +217,14 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
@Override @Override
public void run() { public void run() {
if (location == null) { if (location == null) {
location = getMyApplication().getLocationProvider().getLastKnownLocation(); location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
} }
if (location == null) {
return; boolean useCenter = location == null;
} latLon = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(false); adapter.setUseCenter(useCenter);
adapter.setLocation(new LatLon(location.getLatitude(), location.getLongitude())); adapter.setLocation(latLon);
adapter.setHeading(heading != null ? heading : 99); adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });
@ -260,16 +265,11 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
} }
private void sortFavourites() { private void sortFavourites() {
if (location != null) {
latLon = new LatLon(location.getLatitude(), location.getLongitude());
} else if (sortByDist) {
return;
}
final Collator inst = Collator.getInstance(); final Collator inst = Collator.getInstance();
Collections.sort(favouritePoints, new Comparator<FavouritePoint>() { Collections.sort(favouritePoints, new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint lhs, FavouritePoint rhs) { public int compare(FavouritePoint lhs, FavouritePoint rhs) {
if (sortByDist) { if (sortByDist && latLon != null) {
double ld = MapUtils.getDistance(latLon, lhs.getLatitude(), double ld = MapUtils.getDistance(latLon, lhs.getLatitude(),
lhs.getLongitude()); lhs.getLongitude());
double rd = MapUtils.getDistance(latLon, rhs.getLatitude(), double rd = MapUtils.getDistance(latLon, rhs.getLatitude(),

View file

@ -102,7 +102,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, holder.iconDirection, R.drawable.ic_direction_arrow, heading, holder.iconDirection, R.drawable.ic_direction_arrow,
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()), holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
screenOrientation, mapActivity.getMyApplication(), mapActivity, true); screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -196,7 +196,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, markerImageViewToUpdate, drawableResToUpdate, heading, markerImageViewToUpdate, drawableResToUpdate,
showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon, showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon,
screenOrientation, mapActivity.getMyApplication(), mapActivity, true); screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -395,7 +395,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0, heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0,
itemViewHolder.distance, markerLatLon, itemViewHolder.distance, markerLatLon,
screenOrientation, app, mapActivity, true); screenOrientation, app, true);
} else if (holder instanceof MapMarkerHeaderViewHolder) { } else if (holder instanceof MapMarkerHeaderViewHolder) {
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder; final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
final Object header = getItem(position); final Object header = getItem(position);

View file

@ -659,7 +659,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
heading, direction, distanceText, heading, direction, distanceText,
location.getLatitude(), location.getLatitude(),
location.getLongitude(), location.getLongitude(),
screenOrientation, getMyApplication(), getMapActivity()); screenOrientation, getMyApplication());
} }
public static void showDialog(DialogFragment parentFragment, String text) { public static void showDialog(DialogFragment parentFragment, String text) {

View file

@ -526,6 +526,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
heading, direction, distanceText, heading, direction, distanceText,
listItem.getSearchResult().location.getLatitude(), listItem.getSearchResult().location.getLatitude(),
listItem.getSearchResult().location.getLongitude(), listItem.getSearchResult().location.getLongitude(),
screenOrientation, app, activity); screenOrientation, app);
} }
} }

View file

@ -22,37 +22,37 @@ public class DirectionDrawable extends Drawable {
Paint paintRouteDirection; Paint paintRouteDirection;
float width; float width;
float height; float height;
Context ctx;
private float angle; private float angle;
int resourceId = -1; int resourceId = -1;
Drawable arrowImage ; Drawable arrowImage ;
private OsmandApplication app;
public DirectionDrawable(Context ctx, float width, float height, int resourceId, int clrId) { public DirectionDrawable(OsmandApplication ctx, float width, float height, int resourceId, int clrId) {
this(ctx, width, height); this(ctx, width, height);
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache(); IconsCache iconsCache = ctx.getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId); arrowImage = iconsCache.getIcon(resourceId, clrId);
this.resourceId = resourceId; this.resourceId = resourceId;
} }
public DirectionDrawable(Context ctx, float width, float height) { public DirectionDrawable(OsmandApplication app, float width, float height) {
this.ctx = ctx; this.app = app;
this.width = width; this.width = width;
this.height = height; this.height = height;
paintRouteDirection = new Paint(); paintRouteDirection = new Paint();
paintRouteDirection.setStyle(Paint.Style.FILL_AND_STROKE); paintRouteDirection.setStyle(Paint.Style.FILL_AND_STROKE);
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.color_unknown)); paintRouteDirection.setColor(app.getResources().getColor(R.color.color_unknown));
paintRouteDirection.setAntiAlias(true); paintRouteDirection.setAntiAlias(true);
} }
public void setImage(int resourceId, int clrId) { public void setImage(int resourceId, int clrId) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache(); IconsCache iconsCache = app.getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId); arrowImage = iconsCache.getIcon(resourceId, clrId);
this.resourceId = resourceId; this.resourceId = resourceId;
onBoundsChange(getBounds()); onBoundsChange(getBounds());
} }
public void setImage(int resourceId) { public void setImage(int resourceId) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache(); IconsCache iconsCache = app.getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, 0); arrowImage = iconsCache.getIcon(resourceId, 0);
this.resourceId = resourceId; this.resourceId = resourceId;
onBoundsChange(getBounds()); onBoundsChange(getBounds());
@ -62,10 +62,10 @@ public class DirectionDrawable extends Drawable {
public void setColorId(int clrId) { public void setColorId(int clrId) {
// R.color.color_ok, R.color.color_unknown, R.color.color_warning // R.color.color_ok, R.color.color_unknown, R.color.color_warning
if(arrowImage != null) { if(arrowImage != null) {
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache(); IconsCache iconsCache = app.getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId); arrowImage = iconsCache.getIcon(resourceId, clrId);
} else { } else {
paintRouteDirection.setColor(ctx.getResources().getColor(clrId)); paintRouteDirection.setColor(app.getResources().getColor(clrId));
} }
} }
@ -157,7 +157,7 @@ public class DirectionDrawable extends Drawable {
DisplayMetrics dm = new DisplayMetrics(); DisplayMetrics dm = new DisplayMetrics();
Matrix pathTransform = new Matrix(); Matrix pathTransform = new Matrix();
WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); WindowManager mgr = (WindowManager) app.getSystemService(Context.WINDOW_SERVICE);
mgr.getDefaultDisplay().getMetrics(dm); mgr.getDefaultDisplay().getMetrics(dm);
pathTransform.postScale(dm.density, dm.density); pathTransform.postScale(dm.density, dm.density);
path.transform(pathTransform); path.transform(pathTransform);

View file

@ -252,7 +252,7 @@ public class MapMarkersWidgetsFactory {
DirectionDrawable dd; DirectionDrawable dd;
if (!(arrowImg.getDrawable() instanceof DirectionDrawable)) { if (!(arrowImg.getDrawable() instanceof DirectionDrawable)) {
newImage = true; newImage = true;
dd = new DirectionDrawable(map, arrowImg.getWidth(), arrowImg.getHeight()); dd = new DirectionDrawable(map.getMyApplication(), arrowImg.getWidth(), arrowImg.getHeight());
} else { } else {
dd = (DirectionDrawable) arrowImg.getDrawable(); dd = (DirectionDrawable) arrowImg.getDrawable();
} }