Refactoring FavoriteImageDrawable

This commit is contained in:
Dima-1 2020-06-16 22:42:10 +03:00
parent 928b77d29e
commit 6089a0a1ca
24 changed files with 236 additions and 224 deletions

View file

@ -32,7 +32,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.util.MapUtils;
@ -232,7 +232,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
}
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, app.getFavorites().getColorWithCategory(favorite,
icon.setImageDrawable(PointImageDrawable.getFromFavorite(activity, app.getFavorites().getColorWithCategory(favorite,
app.getResources().getColor(R.color.color_favorite)), false, favorite));
app.getUIUtilities().updateLocationView(cache, direction, distanceText,

View file

@ -47,7 +47,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -463,7 +463,7 @@ public class FavoritesSearchFragment extends DialogFragment {
TextView title = (TextView) view.findViewById(R.id.title);
TextView subtitle = (TextView) view.findViewById(R.id.subtitle);
imageView.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity,
imageView.setImageDrawable(PointImageDrawable.getFromFavorite(activity,
helper.getColorWithCategory(point, getResources().getColor(R.color.color_favorite)),
false, point));
title.setText(point.getDisplayName(app));

View file

@ -47,7 +47,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.base.OsmandExpandableListFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
@ -1032,7 +1032,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
int color = visible
? app.getFavorites().getColorWithCategory(model, getResources().getColor(R.color.color_favorite))
: ContextCompat.getColor(app, disabledIconColor);
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), color, false, model));
icon.setImageDrawable(PointImageDrawable.getFromFavorite(getActivity(), color, false, model));
int iconSize = (int) getResources().getDimension(R.dimen.favorites_my_places_icon_size);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(iconSize, iconSize, CENTER);
icon.setLayoutParams(lp);

View file

@ -8,7 +8,6 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import net.osmand.data.DataTileManager;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
@ -17,7 +16,7 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.OsmandMapLayer;
@ -86,11 +85,10 @@ public class AudioNotesLayer extends OsmandMapLayer implements
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.audio_video_icon_color), true,
new FavouritePoint(0, 0, "", ""));
fid.setAlpha(0.8f);
fid.drawSmallPoint(canvas, x, y, textScale);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.audio_video_icon_color), true);
pointImageDrawable.setAlpha(0.8f);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} else {
fullObjects.add(o);
@ -117,12 +115,10 @@ public class AudioNotesLayer extends OsmandMapLayer implements
} else {
iconId = R.drawable.mx_special_video_camera;
}
FavouritePoint fp = new FavouritePoint(0, 0, "", "");
fp.setIconId(iconId);
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.audio_video_icon_color), true, fp);
fid.setAlpha(0.8f);
fid.drawPoint(canvas, x, y, textScale, false);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.audio_video_icon_color), true, iconId);
pointImageDrawable.setAlpha(0.8f);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
@Override

View file

@ -13,6 +13,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import net.osmand.GPXUtilities;
@ -27,7 +28,7 @@ import java.util.TreeMap;
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
import static net.osmand.data.FavouritePoint.DEFAULT_UI_ICON_ID;
public class FavoriteImageDrawable extends Drawable {
public class PointImageDrawable extends Drawable {
private boolean withShadow;
private boolean synced;
@ -51,34 +52,29 @@ public class FavoriteImageDrawable extends Drawable {
private ColorFilter grayFilter;
private float scale = 1.0f;
private FavoriteImageDrawable(Context ctx, @ColorInt int color, boolean withShadow, boolean synced,
FavouritePoint point) {
this.withShadow = withShadow;
this.synced = synced;
Resources res = ctx.getResources();
UiUtilities uiUtilities = ((OsmandApplication) ctx.getApplicationContext()).getUIUtilities();
int overlayIconId = point != null ? point.getOverlayIconId(ctx) : 0;
private PointImageDrawable(PointInfo pointInfo) {
this.withShadow = pointInfo.withShadow;
this.synced = pointInfo.synced;
Resources res = pointInfo.ctx.getResources();
UiUtilities uiUtilities = ((OsmandApplication) pointInfo.ctx.getApplicationContext()).getUIUtilities();
int overlayIconId = pointInfo.overlayIconId;
int uiIconId;
if (overlayIconId != 0) {
favIcon = uiUtilities.getIcon(getMapIconId(ctx, overlayIconId), R.color.color_white);
uiIconId = overlayIconId;
} else {
favIcon = res.getDrawable(R.drawable.mm_special_star);
uiIconId = DEFAULT_UI_ICON_ID;
}
int col = color == 0 ? res.getColor(R.color.color_favorite) : color;
favIcon = uiUtilities.getIcon(getMapIconId(pointInfo.ctx, overlayIconId), R.color.color_white);
uiIconId = overlayIconId;
int col = pointInfo.color == 0 ? res.getColor(R.color.color_favorite) : pointInfo.color;
uiListIcon = uiUtilities.getIcon(uiIconId, R.color.color_white);
int uiBackgroundIconId = point != null ? point.getBackgroundType().getIconId() : R.drawable.bg_point_circle;
int uiBackgroundIconId = pointInfo.backgroundType.getIconId();
uiBackgroundIcon = uiUtilities.getPaintedIcon(uiBackgroundIconId, col);
int mapBackgroundIconIdTop = getMapBackgroundIconId(ctx, point, "top");
int mapBackgroundIconIdCenter = getMapBackgroundIconId(ctx, point, "center");
int mapBackgroundIconIdBottom = getMapBackgroundIconId(ctx, point, "bottom");
int mapBackgroundIconIdTop = getMapBackgroundIconId(pointInfo, "top", false);
int mapBackgroundIconIdCenter = getMapBackgroundIconId(pointInfo, "center", false);
int mapBackgroundIconIdBottom = getMapBackgroundIconId(pointInfo, "bottom", false);
favBackgroundTop = BitmapFactory.decodeResource(res, mapBackgroundIconIdTop);
favBackgroundCenter = BitmapFactory.decodeResource(res, mapBackgroundIconIdCenter);
favBackgroundBottom = BitmapFactory.decodeResource(res, mapBackgroundIconIdBottom);
int mapBackgroundIconIdTopSmall = getMapBackgroundIconIdSmall(ctx, point, "top");
int mapBackgroundIconIdCenterSmall = getMapBackgroundIconIdSmall(ctx, point, "center");
int mapBackgroundIconIdBottomSmall = getMapBackgroundIconIdSmall(ctx, point, "bottom");
int mapBackgroundIconIdTopSmall = getMapBackgroundIconId(pointInfo, "top", true);
int mapBackgroundIconIdCenterSmall = getMapBackgroundIconId(pointInfo, "center", true);
int mapBackgroundIconIdBottomSmall = getMapBackgroundIconId(pointInfo, "bottom", true);
favBackgroundTopSmall = BitmapFactory.decodeResource(res, mapBackgroundIconIdTopSmall);
favBackgroundCenterSmall = BitmapFactory.decodeResource(res, mapBackgroundIconIdCenterSmall);
favBackgroundBottomSmall = BitmapFactory.decodeResource(res, mapBackgroundIconIdBottomSmall);
@ -96,24 +92,13 @@ public class FavoriteImageDrawable extends Drawable {
.replaceFirst("mx_", "mm_"), "drawable", ctx.getPackageName());
}
private int getMapBackgroundIconIdSmall(Context ctx, FavouritePoint point, String layer) {
if (point != null) {
int iconId = point.getBackgroundType().getIconId();
String iconName = ctx.getResources().getResourceEntryName(iconId);
return ctx.getResources().getIdentifier("ic_" + iconName + "_" + layer + "_small",
"drawable", ctx.getPackageName());
}
return R.drawable.ic_white_shield_small;
}
private int getMapBackgroundIconId(Context ctx, FavouritePoint point, String layer) {
if (point != null) {
int iconId = point.getBackgroundType().getIconId();
String iconName = ctx.getResources().getResourceEntryName(iconId);
return ctx.getResources().getIdentifier("ic_" + iconName + "_" + layer
, "drawable", ctx.getPackageName());
}
return R.drawable.ic_white_favorite_shield;
private int getMapBackgroundIconId(PointInfo pointInfo, String layer, boolean isSmall) {
Context ctx = pointInfo.ctx;
int iconId = pointInfo.backgroundType.getIconId();
String iconName = ctx.getResources().getResourceEntryName(iconId);
String suffix = isSmall ? "_small" : "";
return ctx.getResources().getIdentifier("ic_" + iconName + "_" + layer + suffix,
"drawable", ctx.getPackageName());
}
@Override
@ -220,6 +205,7 @@ public class FavoriteImageDrawable extends Drawable {
public void setAlpha(float alpha) {
setAlpha((int) (255 * alpha));
}
@Override
public void setAlpha(int alpha) {
paintBackground.setAlpha(alpha);
@ -234,52 +220,96 @@ public class FavoriteImageDrawable extends Drawable {
this.scale = scale;
}
private static TreeMap<String, FavoriteImageDrawable> cache = new TreeMap<>();
private static TreeMap<String, PointImageDrawable> cache = new TreeMap<>();
private static FavoriteImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow,
boolean synced, FavouritePoint point) {
String uniqueId = "";
if (point != null) {
uniqueId = point.getIconEntryName(ctx);
uniqueId += point.getBackgroundType().name();
}
color = color | 0xff000000;
int hash = (color << 4) + ((withShadow ? 1 : 0) << 2) + ((synced ? 3 : 0) << 2);
private static PointImageDrawable getOrCreate(@NonNull PointInfo pointInfo) {
String uniqueId = pointInfo.ctx.getResources().getResourceEntryName(pointInfo.overlayIconId);
uniqueId += pointInfo.backgroundType.name();
int color = pointInfo.color | 0xff000000;
int hash = (color << 4) + ((pointInfo.withShadow ? 1 : 0) << 2) + ((pointInfo.synced ? 3 : 0) << 2);
uniqueId = hash + uniqueId;
FavoriteImageDrawable drawable = cache.get(uniqueId);
PointImageDrawable drawable = cache.get(uniqueId);
if (drawable == null) {
drawable = new FavoriteImageDrawable(ctx, color, withShadow, synced, point);
drawable = new PointImageDrawable(pointInfo);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
cache.put(uniqueId, drawable);
}
return drawable;
}
public static FavoriteImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow,
FavouritePoint point) {
return getOrCreate(ctx, color, withShadow, false, point);
public static PointImageDrawable getOrCreateSyncedIcon(Context ctx, @ColorInt int color, FavouritePoint point) {
return getFromFavorite(ctx, color, false, true, point);
}
public static FavoriteImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow,
GPXUtilities.WptPt pt) {
return getOrCreate(ctx, color, withShadow, false, getFavouriteFromWpt(ctx, pt));
public static PointImageDrawable getOrCreateSyncedIcon(Context ctx, @ColorInt int color, GPXUtilities.WptPt wpt) {
return getFromWpt(ctx, color, false, true, wpt);
}
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context ctx, @ColorInt int color, FavouritePoint point) {
return getOrCreate(ctx, color, false, true, point);
public static PointImageDrawable getFromWpt(Context ctx, @ColorInt int color, boolean withShadow,
GPXUtilities.WptPt wpt) {
return getFromWpt(ctx, color, withShadow, false, wpt);
}
public static FavoriteImageDrawable getOrCreateSyncedIcon(Context ctx, @ColorInt int color, GPXUtilities.WptPt pt) {
return getOrCreate(ctx, color, false, true, getFavouriteFromWpt(ctx, pt));
}
private static FavouritePoint getFavouriteFromWpt(Context ctx, GPXUtilities.WptPt pt) {
FavouritePoint point = null;
if (pt != null) {
point = new FavouritePoint(pt.getLatitude(), pt.getLongitude(), pt.name, pt.category);
point.setIconIdFromName(ctx, pt.getIconNameOrDefault());
point.setBackgroundType(BackgroundType.getByTypeName(pt.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
public static PointImageDrawable getFromWpt(Context ctx, @ColorInt int color, boolean withShadow, boolean synced,
GPXUtilities.WptPt wpt) {
if (wpt != null) {
int overlayIconId = ctx.getResources().getIdentifier("mx_" + wpt.getIconNameOrDefault(),
"drawable", ctx.getPackageName());
return getOrCreate(ctx, color, withShadow, synced, overlayIconId,
BackgroundType.getByTypeName(wpt.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
} else {
return getOrCreate(ctx, color, withShadow);
}
}
public static PointImageDrawable getFromFavorite(Context ctx, @ColorInt int color, boolean withShadow,
FavouritePoint favoritePoint) {
return getFromFavorite(ctx, color, withShadow, false, favoritePoint);
}
public static PointImageDrawable getFromFavorite(Context ctx, @ColorInt int color, boolean withShadow,
boolean synced, FavouritePoint favoritePoint) {
if (favoritePoint != null) {
return getOrCreate(ctx, color, withShadow, synced, favoritePoint.getOverlayIconId(ctx),
favoritePoint.getBackgroundType());
} else {
return getOrCreate(ctx, color, withShadow);
}
}
public static PointImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow) {
return getOrCreate(ctx, color, withShadow, DEFAULT_UI_ICON_ID);
}
public static PointImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow, int overlayIconId) {
return getOrCreate(ctx, color, withShadow, false, overlayIconId, BackgroundType.CIRCLE);
}
public static PointImageDrawable getOrCreate(Context ctx, @ColorInt int color, boolean withShadow, boolean synced,
int overlayIconId, @NonNull BackgroundType backgroundType) {
overlayIconId = overlayIconId == 0 ? DEFAULT_UI_ICON_ID : overlayIconId;
PointInfo pointInfo = new PointInfo(ctx, color, withShadow, overlayIconId, backgroundType);
pointInfo.synced = synced;
return getOrCreate(pointInfo);
}
private static class PointInfo {
Context ctx;
@ColorInt
int color;
boolean withShadow;
boolean synced = false;
@DrawableRes
int overlayIconId;
BackgroundType backgroundType;
private PointInfo(Context ctx, int color, boolean withShadow, int overlayIconId, BackgroundType backgroundType) {
this.ctx = ctx;
this.color = color;
this.withShadow = withShadow;
this.overlayIconId = overlayIconId;
this.backgroundType = backgroundType;
}
return point;
}
}

View file

@ -21,7 +21,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.myplaces.FavoritesActivity;
@ -144,7 +144,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
}
int iconColor = app.getFavorites().getColorWithCategory(point, getResources().getColor(R.color.color_favorite));
Drawable favoriteIcon = FavoriteImageDrawable.getOrCreate(app, iconColor, false, point);
Drawable favoriteIcon = PointImageDrawable.getFromFavorite(app, iconColor, false, point);
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(favoriteIcon);
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),
point.getLongitude()));

View file

@ -23,7 +23,7 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.routing.AlarmInfo;
@ -776,14 +776,14 @@ public class WaypointHelper {
}
} else if (type == FAVORITES ) {
return FavoriteImageDrawable.getOrCreate(uiCtx,
return PointImageDrawable.getFromFavorite(uiCtx,
app.getFavorites().getColorWithCategory((FavouritePoint) point,
app.getResources().getColor(R.color.color_favorite)), false, (FavouritePoint) point);
} else if (type == WAYPOINTS) {
if (point instanceof WptLocationPoint) {
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, ((WptLocationPoint) point).getPt());
return PointImageDrawable.getFromWpt(uiCtx, point.getColor(), false, ((WptLocationPoint) point).getPt());
} else if (point instanceof GPXUtilities.WptPt) {
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false, (GPXUtilities.WptPt) point);
return PointImageDrawable.getFromWpt(uiCtx, point.getColor(), false, (GPXUtilities.WptPt) point);
} else {
return null;
}

View file

@ -15,7 +15,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
@ -126,7 +126,7 @@ public class FavouritePointMenuController extends MenuController {
public Drawable getRightIcon() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(),
return PointImageDrawable.getFromFavorite(mapActivity.getMyApplication(),
mapActivity.getMyApplication().getFavorites().getColorWithCategory(fav,
ContextCompat.getColor(mapActivity, R.color.color_favorite)), false, fav);
} else {

View file

@ -15,7 +15,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.wikivoyage.menu.WikivoyageWptPtMenuBuilder;
@ -83,7 +83,7 @@ public class WptPtMenuController extends MenuController {
public Drawable getRightIcon() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(),
return PointImageDrawable.getFromWpt(mapActivity.getMyApplication(),
wpt.getColor(ContextCompat.getColor(mapActivity, R.color.gpx_color_point)), false, wpt);
} else {
return null;

View file

@ -21,7 +21,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.util.Algorithms;
@ -313,7 +313,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
@Override
public Drawable getNameIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, getFavorite());
return PointImageDrawable.getFromFavorite(getMapActivity(), getPointColor(), false, getFavorite());
}
@Override

View file

@ -25,7 +25,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.util.Algorithms;
@ -415,7 +415,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
point.setBackgroundType(backgroundType);
point.setIconId(iconId);
}
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, point);
return PointImageDrawable.getFromFavorite(getMapActivity(), getPointColor(), false, point);
}
@Override

View file

@ -24,7 +24,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
import net.osmand.util.Algorithms;
@ -365,7 +365,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
@Override
public Drawable getNameIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, wpt);
return PointImageDrawable.getFromWpt(getMapActivity(), getPointColor(), false, wpt);
}
@Override

View file

@ -27,7 +27,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
import net.osmand.util.Algorithms;
@ -411,7 +411,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
point.setBackgroundType(backgroundTypeName);
point.setIconName(iconName);
}
return FavoriteImageDrawable.getOrCreate(getMapActivity(), getPointColor(), false, point);
return PointImageDrawable.getFromWpt(getMapActivity(), getPointColor(), false, point);
}
@Override

View file

@ -13,7 +13,7 @@ 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 net.osmand.plus.base.PointImageDrawable;
import java.util.List;
@ -47,7 +47,7 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
favouritesViewHolder.title.setText(favouritePoint.getDisplayName(app));
favouritesViewHolder.description.setText(favouritePoint.getCategoryDisplayName(app));
favouritesViewHolder.favouriteImage.setImageDrawable(
FavoriteImageDrawable.getOrCreate(app,
PointImageDrawable.getFromFavorite(app,
app.getFavorites().getColorWithCategory(favouritePoint,
ContextCompat.getColor(app, R.color.color_favorite)), false, favouritePoint));
app.getUIUtilities().updateLocationView(cache, favouritesViewHolder.arrowImage, favouritesViewHolder.distance,

View file

@ -19,7 +19,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
@ -67,7 +67,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
WptPt wpt = getItem(position);
holder.iconDirection.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false, wpt));
holder.icon.setImageDrawable(PointImageDrawable.getFromWpt(app, wpt.getColor(), false, wpt));
holder.mainLayout.setBackgroundColor(getResolvedColor(nightTheme ? R.color.list_background_color_dark : R.color.list_background_color_light));
holder.title.setTextColor(getResolvedColor(nightTheme ? R.color.text_color_primary_dark : R.color.text_color_primary_light));
holder.divider.setBackgroundColor(getResolvedColor(nightTheme ? R.color.coordinate_input_edit_text_normal_dark : R.color.divider_color_light));

View file

@ -67,7 +67,7 @@ import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.base.OsmandExpandableListFragment;
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
@ -1114,7 +1114,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
} else {
description.setVisibility(View.GONE);
}
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false, wpt));
icon.setImageDrawable(PointImageDrawable.getFromWpt(getActivity(), groupColor, false, wpt));
} else {
boolean showAll = gpxItem == null;

View file

@ -16,7 +16,6 @@ import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
@ -24,7 +23,7 @@ import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -132,8 +131,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
} else {
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
FavoriteImageDrawable fid = getFavoriteImageDrawable(backgroundColorRes, 0);
fid.drawSmallPoint(canvas, x, y, textScale);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, backgroundColorRes), true);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
} else {
fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
@ -154,8 +154,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
iconId = R.drawable.mx_special_symbol_check_mark;
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
FavoriteImageDrawable fid = getFavoriteImageDrawable(backgroundColorRes, iconId);
fid.drawPoint(canvas, x, y, textScale, false);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, backgroundColorRes), true, iconId);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
@ -163,16 +164,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
}
}
private FavoriteImageDrawable getFavoriteImageDrawable(int backgroundColorRes, int iconId) {
FavouritePoint fp = new FavouritePoint(0, 0, "", "");
fp.setIconId(iconId);
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, backgroundColorRes), true,
fp);
fid.setAlpha(0.8f);
return fid;
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {

View file

@ -9,14 +9,13 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.osm.edit.Entity;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
@ -79,12 +78,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
private void drawPoint(Canvas canvas, OsmPoint o, float x, float y) {
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
FavouritePoint fp = new FavouritePoint(0, 0, "", "");
fp.setIconId(R.drawable.mx_special_information);
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.created_poi_icon_color), true, fp);
fid.setAlpha(0.8f);
fid.drawPoint(canvas, x, y, textScale, false);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
ContextCompat.getColor(activity, R.color.created_poi_icon_color), true,
R.drawable.mx_special_information);
pointImageDrawable.setAlpha(0.8f);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
@Override

View file

@ -10,7 +10,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
@ -107,7 +107,7 @@ public class ParkingPositionMenuController extends MenuController {
public Drawable getRightIcon() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
return FavoriteImageDrawable.getOrCreate(mapActivity.getMyApplication(),
return PointImageDrawable.getFromFavorite(mapActivity.getMyApplication(),
ContextCompat.getColor(mapActivity, R.color.parking_icon_background), false, fav);
} else {
return null;

View file

@ -26,7 +26,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
@ -377,11 +377,11 @@ public class QuickSearchListItem {
return getIcon(app, R.drawable.ic_action_world_globe);
case FAVORITE:
FavouritePoint fav = (FavouritePoint) searchResult.object;
return FavoriteImageDrawable.getOrCreate(app,
app.getFavorites().getColorWithCategory(fav, app.getResources().getColor(R.color.color_favorite)), false, fav);
int color = app.getFavorites().getColorWithCategory(fav, app.getResources().getColor(R.color.color_favorite));
return PointImageDrawable.getFromFavorite(app, color, false, fav);
case FAVORITE_GROUP:
FavoriteGroup group = (FavoriteGroup) searchResult.object;
int color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_favorite, color | 0xff000000);
case REGION:
return getIcon(app, R.drawable.ic_world_globe_dark);
@ -395,7 +395,7 @@ public class QuickSearchListItem {
}
case WPT:
WptPt wpt = (WptPt) searchResult.object;
return FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false, wpt);
return PointImageDrawable.getFromWpt(app, wpt.getColor(), false, wpt);
case UNKNOWN_NAME_FILTER:
break;
}

View file

@ -21,7 +21,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.views.ContextMenuLayer.ApplyMovedObjectCallback;
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
@ -103,19 +103,19 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
for (FavoriteGroup group : favorites.getFavoriteGroups()) {
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
boolean synced = mapMarkersHelper.getMarkersGroup(group) != null;
for (FavouritePoint o : group.getPoints()) {
double lat = o.getLatitude();
double lon = o.getLongitude();
if (o.isVisible() && o != contextMenuLayer.getMoveableObject()
for (FavouritePoint favoritePoint : group.getPoints()) {
double lat = favoritePoint.getLatitude();
double lon = favoritePoint.getLongitude();
if (favoritePoint.isVisible() && favoritePoint != contextMenuLayer.getMoveableObject()
&& lat >= latLonBounds.bottom && lat <= latLonBounds.top
&& lon >= latLonBounds.left && lon <= latLonBounds.right) {
MapMarker marker = null;
if (synced) {
if ((marker = mapMarkersHelper.getMapMarker(o)) == null) {
if ((marker = mapMarkersHelper.getMapMarker(favoritePoint)) == null) {
continue;
}
}
cache.add(o);
cache.add(favoritePoint);
float x = tileBox.getPixXFromLatLon(lat, lon);
float y = tileBox.getPixYFromLatLon(lat, lon);
@ -125,23 +125,23 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
if (marker != null && marker.history) {
color = grayColor;
} else {
color = favorites.getColorWithCategory(o,defaultColor);
color = favorites.getColorWithCategory(favoritePoint,defaultColor);
}
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), color,
true, o);
fid.drawSmallPoint(canvas, x, y, textScale);
PointImageDrawable pointImageDrawable = PointImageDrawable.getFromFavorite(
view.getContext(), color,true, favoritePoint);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(lat, lon));
} else {
fullObjects.add(new Pair<>(o, marker));
fullObjects.add(new Pair<>(favoritePoint, marker));
fullObjectsLatLon.add(new LatLon(lat, lon));
}
}
}
for (Pair<FavouritePoint, MapMarker> pair : fullObjects) {
FavouritePoint o = pair.first;
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
drawBigPoint(canvas, o, x, y, pair.second, textScale);
FavouritePoint favoritePoint = pair.first;
float x = tileBox.getPixXFromLatLon(favoritePoint.getLatitude(), favoritePoint.getLongitude());
float y = tileBox.getPixYFromLatLon(favoritePoint.getLatitude(), favoritePoint.getLongitude());
drawBigPoint(canvas, favoritePoint, x, y, pair.second, textScale);
}
}
this.fullObjectsLatLon = fullObjectsLatLon;
@ -154,17 +154,19 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
}
private void drawBigPoint(Canvas canvas, FavouritePoint o, float x, float y, @Nullable MapMarker marker, float textScale) {
FavoriteImageDrawable fid;
private void drawBigPoint(Canvas canvas, FavouritePoint favoritePoint, float x, float y, @Nullable MapMarker marker,
float textScale) {
PointImageDrawable pointImageDrawable;
boolean history = false;
if (marker != null) {
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), favorites.getColorWithCategory(o,defaultColor), o);
pointImageDrawable = PointImageDrawable.getOrCreateSyncedIcon(view.getContext(),
favorites.getColorWithCategory(favoritePoint,defaultColor), favoritePoint);
history = marker.history;
} else {
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), favorites.getColorWithCategory(o, defaultColor),
true, o);
pointImageDrawable = PointImageDrawable.getFromFavorite(view.getContext(),
favorites.getColorWithCategory(favoritePoint, defaultColor),true, favoritePoint);
}
fid.drawPoint(canvas, x, y, textScale, history);
pointImageDrawable.drawPoint(canvas, x, y, textScale, history);
}
@Override

View file

@ -40,7 +40,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.TrackChartPoints;
import net.osmand.plus.render.OsmandRenderer;
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
@ -380,20 +380,20 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
List<Pair<WptPt, MapMarker>> fullObjects = new ArrayList<>();
int fileColor = getFileColor(g);
boolean synced = mapMarkersHelper.getMarkersGroup(g.getGpxFile()) != null;
for (WptPt o : getListStarPoints(g)) {
if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top
&& o.lon >= latLonBounds.left && o.lon <= latLonBounds.right
&& o != contextMenuLayer.getMoveableObject()) {
pointFileMap.put(o, g);
for (WptPt wpt : getListStarPoints(g)) {
if (wpt.lat >= latLonBounds.bottom && wpt.lat <= latLonBounds.top
&& wpt.lon >= latLonBounds.left && wpt.lon <= latLonBounds.right
&& wpt != contextMenuLayer.getMoveableObject()) {
pointFileMap.put(wpt, g);
MapMarker marker = null;
if (synced) {
if ((marker = mapMarkersHelper.getMapMarker(o)) == null) {
if ((marker = mapMarkersHelper.getMapMarker(wpt)) == null) {
continue;
}
}
cache.add(o);
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
cache.add(wpt);
float x = tileBox.getPixXFromLatLon(wpt.lat, wpt.lon);
float y = tileBox.getPixYFromLatLon(wpt.lat, wpt.lon);
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
@ColorInt
@ -401,26 +401,26 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
if (marker != null && marker.history) {
color = grayColor;
} else {
color = getPointColor(o, fileColor);
color = getPointColor(wpt, fileColor);
}
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), color,
true, o);
fid.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
PointImageDrawable pointImageDrawable = PointImageDrawable.getFromWpt(view.getContext(), color,
true, wpt);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(wpt.lat, wpt.lon));
} else {
fullObjects.add(new Pair<>(o, marker));
fullObjectsLatLon.add(new LatLon(o.lat, o.lon));
fullObjects.add(new Pair<>(wpt, marker));
fullObjectsLatLon.add(new LatLon(wpt.lat, wpt.lon));
}
}
if (o == contextMenuLayer.getMoveableObject()) {
pointFileMap.put(o, g);
if (wpt == contextMenuLayer.getMoveableObject()) {
pointFileMap.put(wpt, g);
}
}
for (Pair<WptPt, MapMarker> pair : fullObjects) {
WptPt o = pair.first;
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
drawBigPoint(canvas, o, fileColor, x, y, pair.second, textScale);
WptPt wpt = pair.first;
float x = tileBox.getPixXFromLatLon(wpt.lat, wpt.lon);
float y = tileBox.getPixYFromLatLon(wpt.lat, wpt.lon);
drawBigPoint(canvas, wpt, fileColor, x, y, pair.second, textScale);
}
}
if (trackChartPoints != null) {
@ -494,17 +494,17 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
return g.getColor() == 0 ? defPointColor : g.getColor();
}
private void drawBigPoint(Canvas canvas, WptPt o, int fileColor, float x, float y, @Nullable MapMarker marker, float textScale) {
int pointColor = getPointColor(o, fileColor);
FavoriteImageDrawable fid;
private void drawBigPoint(Canvas canvas, WptPt wpt, int fileColor, float x, float y, @Nullable MapMarker marker, float textScale) {
int pointColor = getPointColor(wpt, fileColor);
PointImageDrawable pointImageDrawable;
boolean history = false;
if (marker != null) {
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor, o);
pointImageDrawable = PointImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor, wpt);
history = marker.history;
} else {
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true, o);
pointImageDrawable = PointImageDrawable.getFromWpt(view.getContext(), pointColor, true, wpt);
}
fid.drawPoint(canvas, x, y, textScale, history);
pointImageDrawable.drawPoint(canvas, x, y, textScale, history);
}
@ColorInt

View file

@ -22,7 +22,6 @@ import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher;
import net.osmand.ValueHolder;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
@ -32,7 +31,7 @@ import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
@ -202,10 +201,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
float iconSize = getIconSize(app) * 1.5f * textScale;
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
WaypointHelper wph = app.getWaypointHelper();
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(),
ContextCompat.getColor(app, R.color.osmand_orange), true,
new FavouritePoint(0, 0, "", ""));
fid.setAlpha(0.8f);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(),
ContextCompat.getColor(app, R.color.osmand_orange), true);
pointImageDrawable.setAlpha(0.8f);
for (Amenity o : objects) {
float x = tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation()
.getLongitude());
@ -215,7 +213,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
if (tileBox.containsPoint(x, y, iconSize)) {
if (intersects(boundIntersections, x, y, iconSize, iconSize) ||
(app.getSettings().SHOW_NEARBY_POI.get() && wph.isRouteCalculated() && !wph.isAmenityNoPassed(o))) {
fid.drawSmallPoint(canvas, x, y, textScale);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(),
o.getLocation().getLongitude()));
} else {
@ -241,7 +239,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
}
}
if (id != null) {
fid.drawPoint(canvas, x, y, textScale, false);
pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(),
ContextCompat.getColor(app, R.color.osmand_orange), true,
RenderingIcons.getResId(id));
pointImageDrawable.setAlpha(0.8f);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
}
}

View file

@ -11,7 +11,7 @@ import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import net.osmand.ResultMatcher;
import net.osmand.data.FavouritePoint;
import net.osmand.data.FavouritePoint.BackgroundType;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
@ -20,7 +20,7 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportStop;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -222,11 +222,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(mapActivity,
ContextCompat.getColor(mapActivity, R.color.transport_stop_icon_background), true,
createUIPoint(0));
fid.setAlpha(0.9f);
fid.drawSmallPoint(canvas, x, y, textScale);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(mapActivity,
ContextCompat.getColor(mapActivity, R.color.transport_stop_icon_background),
true,false ,0, BackgroundType.SQUARE);
pointImageDrawable.setAlpha(0.9f);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
} else {
fullObjects.add(o);
}
@ -247,19 +247,12 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
}
}
private FavouritePoint createUIPoint(int iconId) {
FavouritePoint fp = new FavouritePoint(0, 0, "", "");
fp.setIconId(iconId);
fp.setBackgroundType(FavouritePoint.BackgroundType.SQUARE);
return fp;
}
private void drawPoint(Canvas canvas, float textScale, float x, float y, @DrawableRes int iconId) {
FavouritePoint fp = createUIPoint(iconId);
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(mapActivity,
ContextCompat.getColor(mapActivity, R.color.transport_stop_icon_background), true, fp);
fid.setAlpha(0.9f);
fid.drawPoint(canvas, x, y, textScale, false);
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(mapActivity,
ContextCompat.getColor(mapActivity, R.color.transport_stop_icon_background),
true,false ,iconId, BackgroundType.SQUARE);
pointImageDrawable.setAlpha(0.9f);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
@Override