Improve BaseTravelCard
This commit is contained in:
parent
ec6f918422
commit
6d85738816
1 changed files with 21 additions and 5 deletions
|
@ -4,11 +4,15 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.ContextCompat;
|
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.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
public class BaseTravelCard {
|
public abstract class BaseTravelCard {
|
||||||
|
|
||||||
protected OsmandApplication app;
|
protected OsmandApplication app;
|
||||||
protected boolean nightMode;
|
protected boolean nightMode;
|
||||||
|
@ -18,16 +22,28 @@ public class BaseTravelCard {
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract RecyclerView.ViewHolder createViewHolder(@NonNull ViewGroup parent);
|
||||||
|
|
||||||
|
public abstract void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder);
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
protected int getResolvedColor(@ColorRes int colorId) {
|
protected int getResolvedColor(@ColorRes int colorId) {
|
||||||
return ContextCompat.getColor(app, colorId);
|
return ContextCompat.getColor(app, colorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Drawable getIcon(@DrawableRes int iconId, @ColorRes int colorLightId, @ColorRes int colorDarkId) {
|
protected Drawable getContentIcon(@DrawableRes int icon) {
|
||||||
return getIcon(iconId, nightMode ? colorLightId : colorDarkId);
|
return getColoredIcon(icon, R.color.icon_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
|
protected Drawable getActiveIcon(@DrawableRes int icon) {
|
||||||
return app.getIconsCache().getIcon(drawableRes, color);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue