From 6d857388169c5ae0c951a8af8bf4caf1bb415bb1 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 23 Apr 2018 17:28:11 +0300 Subject: [PATCH] Improve BaseTravelCard --- .../explore/travelcards/BaseTravelCard.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/BaseTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/BaseTravelCard.java index 2886fc0678..64021f2102 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/BaseTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/BaseTravelCard.java @@ -4,11 +4,15 @@ import android.graphics.drawable.Drawable; import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.support.v7.widget.RecyclerView; +import android.view.ViewGroup; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; -public class BaseTravelCard { +public abstract class BaseTravelCard { protected OsmandApplication app; protected boolean nightMode; @@ -18,16 +22,28 @@ public class BaseTravelCard { this.nightMode = nightMode; } + public abstract RecyclerView.ViewHolder createViewHolder(@NonNull ViewGroup parent); + + public abstract void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder); + @ColorInt protected int getResolvedColor(@ColorRes int colorId) { return ContextCompat.getColor(app, colorId); } - protected Drawable getIcon(@DrawableRes int iconId, @ColorRes int colorLightId, @ColorRes int colorDarkId) { - return getIcon(iconId, nightMode ? colorLightId : colorDarkId); + protected Drawable getContentIcon(@DrawableRes int icon) { + return getColoredIcon(icon, R.color.icon_color); } - protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) { - return app.getIconsCache().getIcon(drawableRes, color); + protected Drawable getActiveIcon(@DrawableRes int icon) { + return getColoredIcon(icon, R.color.wikivoyage_active_light, R.color.wikivoyage_active_dark); + } + + protected Drawable getColoredIcon(@DrawableRes int icon, @ColorRes int colorLight, @ColorRes int colorDark) { + return getColoredIcon(icon, nightMode ? colorDark : colorLight); + } + + protected Drawable getColoredIcon(@DrawableRes int icon, @ColorRes int color) { + return app.getIconsCache().getIcon(icon, color); } }