Fix 5467
This commit is contained in:
parent
9d75efd61d
commit
d1de3a8dd1
15 changed files with 91 additions and 78 deletions
|
@ -238,7 +238,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
|
||||
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity);
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app);
|
||||
|
||||
name.setText(getName(favorite));
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
|
|
|
@ -242,7 +242,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
|||
TextView distanceText = (TextView) row.findViewById(R.id.distance);
|
||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||
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);
|
||||
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white));
|
||||
options.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -785,7 +785,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
if (dd instanceof DirectionDrawable) {
|
||||
draw = (DirectionDrawable) dd;
|
||||
} else {
|
||||
draw = new DirectionDrawable(SearchPOIActivity.this, 24, 24,
|
||||
draw = new DirectionDrawable(getMyApplication(), 24, 24,
|
||||
R.drawable.ic_direction_arrow, R.color.color_distance);
|
||||
direction.setImageDrawable(draw);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
private static final int ORIENTATION_180 = 2;
|
||||
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
private int screenOrientation;
|
||||
protected LatLon lastUpdatedLocation;
|
||||
|
||||
public static class DashLocationView {
|
||||
public ImageView arrow;
|
||||
|
@ -98,50 +97,61 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
float head = d.getHeading();
|
||||
float mapRotation = d.getMapRotation();
|
||||
LatLon mw = d.getMapViewLocation();
|
||||
Location l = d.getMyLocation();
|
||||
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);
|
||||
boolean useCenter = !d.isMapLinkedToLocation();
|
||||
float h = useCenter ? -mapRotation : head;
|
||||
lastUpdatedLocation = loc;
|
||||
for (DashLocationView lv : distances) {
|
||||
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
|
||||
getMyApplication(), getActivity(), lv.paint);
|
||||
updateLocationView(useCenter, mw, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
|
||||
getMyApplication(), lv.paint);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
|
||||
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,
|
||||
ImageView arrow, TextView txt, double toLat, double toLon,
|
||||
int screenOrientation, OsmandApplication app, Context ctx) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, ctx, true);
|
||||
int screenOrientation, OsmandApplication app) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, true);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
|
||||
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint);
|
||||
int screenOrientation, OsmandApplication app, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, paint);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
|
||||
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint);
|
||||
int screenOrientation, OsmandApplication app, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, paint);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
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];
|
||||
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) {
|
||||
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
|
||||
}
|
||||
|
||||
|
||||
if (arrow != null) {
|
||||
boolean newImage = false;
|
||||
if (arrowResId == 0) {
|
||||
|
@ -150,11 +160,18 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
DirectionDrawable dd;
|
||||
if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
|
||||
dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
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) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
|
@ -168,8 +185,14 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
if (txt != null) {
|
||||
if (fromLoc != null && toLoc != null) {
|
||||
if (paint) {
|
||||
txt.setTextColor(app.getResources().getColor(
|
||||
textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor));
|
||||
int textColorSet = 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));
|
||||
} else {
|
||||
|
|
|
@ -149,7 +149,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
private ApplicationMode previousAppMode;
|
||||
private boolean landscape;
|
||||
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>();
|
||||
private net.osmand.Location myLocation;
|
||||
private LatLon mapViewLocation;
|
||||
private float heading;
|
||||
private boolean mapLinkedToLocation;
|
||||
|
@ -621,10 +620,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
}
|
||||
|
||||
public net.osmand.Location getMyLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
public LatLon getMapViewLocation() {
|
||||
return mapViewLocation;
|
||||
}
|
||||
|
@ -716,7 +711,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
mapViewLocation = mapActivity.getMapLocation();
|
||||
mapRotation = mapActivity.getMapRotate();
|
||||
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
mapActivity.getMapViewTrackingUtilities().setDashboard(this);
|
||||
mapActivity.disableDrawer();
|
||||
dashboardView.setVisibility(View.VISIBLE);
|
||||
|
@ -1218,7 +1212,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
|
||||
public void updateMyLocation(net.osmand.Location location) {
|
||||
myLocation = location;
|
||||
updateLocation(false, true, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MapMarkerDialogHelper {
|
|||
DirectionDrawable dd;
|
||||
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
|
||||
dd = new DirectionDrawable((OsmandApplication) ctx.getApplicationContext(), arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
dd = (DirectionDrawable) arrow.getDrawable();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -9,7 +7,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.IconsCache;
|
||||
|
@ -24,18 +21,21 @@ import java.util.List;
|
|||
|
||||
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 LatLon location;
|
||||
private Float heading;
|
||||
private boolean useCenter;
|
||||
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.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +48,6 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof FavouritesViewHolder) {
|
||||
OsmandApplication app = (OsmandApplication) ((Activity) context).getApplication();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder;
|
||||
FavouritePoint favouritePoint = getItem(position);
|
||||
favouritesViewHolder.title.setText(favouritePoint.getName());
|
||||
|
@ -58,17 +56,16 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
} else {
|
||||
favouritesViewHolder.description.setText(favouritePoint.getCategory());
|
||||
}
|
||||
Location myloc = app.getLocationProvider().getLastKnownLocation();
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(context, favouritePoint.getColor(), false));
|
||||
if (myloc == null) {
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
|
||||
if (location == null) {
|
||||
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.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow));
|
||||
DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage,
|
||||
favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(),
|
||||
screenOrientation, app, context);
|
||||
screenOrientation, app);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,11 +66,16 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
||||
R.layout.recyclerview, null);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
location = getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
|
||||
if (location != null) {
|
||||
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();
|
||||
final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1];
|
||||
title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
|
||||
|
@ -212,14 +217,14 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
@Override
|
||||
public void run() {
|
||||
if (location == null) {
|
||||
location = getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
}
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
adapter.setUseCenter(false);
|
||||
adapter.setLocation(new LatLon(location.getLatitude(), location.getLongitude()));
|
||||
adapter.setHeading(heading != null ? heading : 99);
|
||||
|
||||
boolean useCenter = location == null;
|
||||
latLon = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
|
||||
adapter.setUseCenter(useCenter);
|
||||
adapter.setLocation(latLon);
|
||||
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
@ -260,16 +265,11 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
}
|
||||
|
||||
private void sortFavourites() {
|
||||
if (location != null) {
|
||||
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
||||
} else if (sortByDist) {
|
||||
return;
|
||||
}
|
||||
final Collator inst = Collator.getInstance();
|
||||
Collections.sort(favouritePoints, new Comparator<FavouritePoint>() {
|
||||
@Override
|
||||
public int compare(FavouritePoint lhs, FavouritePoint rhs) {
|
||||
if (sortByDist) {
|
||||
if (sortByDist && latLon != null) {
|
||||
double ld = MapUtils.getDistance(latLon, lhs.getLatitude(),
|
||||
lhs.getLongitude());
|
||||
double rd = MapUtils.getDistance(latLon, rhs.getLatitude(),
|
||||
|
|
|
@ -102,7 +102,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, holder.iconDirection, R.drawable.ic_direction_arrow,
|
||||
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
|
||||
screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
|
||||
screenOrientation, mapActivity.getMyApplication(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -196,7 +196,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, markerImageViewToUpdate, drawableResToUpdate,
|
||||
showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon,
|
||||
screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
|
||||
screenOrientation, mapActivity.getMyApplication(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -395,7 +395,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0,
|
||||
itemViewHolder.distance, markerLatLon,
|
||||
screenOrientation, app, mapActivity, true);
|
||||
screenOrientation, app, true);
|
||||
} else if (holder instanceof MapMarkerHeaderViewHolder) {
|
||||
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final Object header = getItem(position);
|
||||
|
|
|
@ -659,7 +659,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
|
|||
heading, direction, distanceText,
|
||||
location.getLatitude(),
|
||||
location.getLongitude(),
|
||||
screenOrientation, getMyApplication(), getMapActivity());
|
||||
screenOrientation, getMyApplication());
|
||||
}
|
||||
|
||||
public static void showDialog(DialogFragment parentFragment, String text) {
|
||||
|
|
|
@ -526,6 +526,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
heading, direction, distanceText,
|
||||
listItem.getSearchResult().location.getLatitude(),
|
||||
listItem.getSearchResult().location.getLongitude(),
|
||||
screenOrientation, app, activity);
|
||||
screenOrientation, app);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,37 +22,37 @@ public class DirectionDrawable extends Drawable {
|
|||
Paint paintRouteDirection;
|
||||
float width;
|
||||
float height;
|
||||
Context ctx;
|
||||
private float angle;
|
||||
int resourceId = -1;
|
||||
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);
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
IconsCache iconsCache = ctx.getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public DirectionDrawable(Context ctx, float width, float height) {
|
||||
this.ctx = ctx;
|
||||
public DirectionDrawable(OsmandApplication app, float width, float height) {
|
||||
this.app = app;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
paintRouteDirection = new Paint();
|
||||
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);
|
||||
}
|
||||
|
||||
public void setImage(int resourceId, int clrId) {
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
this.resourceId = resourceId;
|
||||
onBoundsChange(getBounds());
|
||||
}
|
||||
|
||||
public void setImage(int resourceId) {
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, 0);
|
||||
this.resourceId = resourceId;
|
||||
onBoundsChange(getBounds());
|
||||
|
@ -62,10 +62,10 @@ public class DirectionDrawable extends Drawable {
|
|||
public void setColorId(int clrId) {
|
||||
// R.color.color_ok, R.color.color_unknown, R.color.color_warning
|
||||
if(arrowImage != null) {
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
} 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();
|
||||
Matrix pathTransform = new Matrix();
|
||||
WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
|
||||
WindowManager mgr = (WindowManager) app.getSystemService(Context.WINDOW_SERVICE);
|
||||
mgr.getDefaultDisplay().getMetrics(dm);
|
||||
pathTransform.postScale(dm.density, dm.density);
|
||||
path.transform(pathTransform);
|
||||
|
|
|
@ -252,7 +252,7 @@ public class MapMarkersWidgetsFactory {
|
|||
DirectionDrawable dd;
|
||||
if (!(arrowImg.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(map, arrowImg.getWidth(), arrowImg.getHeight());
|
||||
dd = new DirectionDrawable(map.getMyApplication(), arrowImg.getWidth(), arrowImg.getHeight());
|
||||
} else {
|
||||
dd = (DirectionDrawable) arrowImg.getDrawable();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue