Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-04-23 16:43:54 +02:00
commit 82ca6ac055
2 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_card_shadow_cr3dp"/>
</item>
<item>
<shape>
<solid android:color="?attr/wikivoyage_card_bg_color"/>
<corners android:radius="3dp"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,48 @@
package net.osmand.plus.wikivoyage.explore.travelcards;
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 net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
public abstract class BaseTravelCard {
protected OsmandApplication app;
protected boolean nightMode;
public BaseTravelCard(OsmandApplication app, boolean nightMode) {
this.app = app;
this.nightMode = nightMode;
}
public abstract void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder);
public abstract int getCardType();
@ColorInt
protected int getResolvedColor(@ColorRes int colorId) {
return ContextCompat.getColor(app, colorId);
}
protected Drawable getContentIcon(@DrawableRes int icon) {
return getColoredIcon(icon, R.color.icon_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);
}
}