Check resource
This commit is contained in:
parent
055c681f4b
commit
0672f140af
1 changed files with 15 additions and 9 deletions
|
@ -5,7 +5,9 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -45,9 +47,13 @@ public class TravelGpxCard extends BaseTravelCard {
|
||||||
holder.user.setText(article.user);
|
holder.user.setText(article.user);
|
||||||
RouteActivityType activityType = RouteActivityType.getTypeFromName(article.activityType);
|
RouteActivityType activityType = RouteActivityType.getTypeFromName(article.activityType);
|
||||||
if (activityType != null) {
|
if (activityType != null) {
|
||||||
holder.activityTypeIcon.setImageDrawable(getActivityTypeIcon(activityType));
|
int iconId = getActivityTypeIcon(activityType);
|
||||||
holder.activityType.setText(getActivityTypeName(activityType));
|
int titleId = getActivityTypeTitle(activityType);
|
||||||
holder.activityTypeLabel.setVisibility(View.VISIBLE);
|
if (iconId > 0 && titleId > 0) {
|
||||||
|
holder.activityTypeIcon.setImageDrawable(getActiveIcon(iconId));
|
||||||
|
holder.activityType.setText(titleId);
|
||||||
|
holder.activityTypeLabel.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
||||||
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));
|
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));
|
||||||
|
@ -71,14 +77,14 @@ public class TravelGpxCard extends BaseTravelCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getActivityTypeIcon(RouteActivityType activityType) {
|
@DrawableRes
|
||||||
int iconId = app.getResources().getIdentifier(activityType.getIcon(), "drawable", app.getPackageName());
|
private int getActivityTypeIcon(RouteActivityType activityType) {
|
||||||
return getActiveIcon(iconId > 0 ? iconId : R.drawable.ic_action_route_distance);
|
return app.getResources().getIdentifier(activityType.getIcon(), "drawable", app.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getActivityTypeName(RouteActivityType activityType) {
|
@StringRes
|
||||||
int titleId = app.getResources().getIdentifier(activityType.getTitle(), "string", app.getPackageName());
|
private int getActivityTypeTitle(RouteActivityType activityType) {
|
||||||
return titleId > 0 ? titleId : R.string.layer_route;
|
return app.getResources().getIdentifier(activityType.getTitle(), "string", app.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSaveButton(final TravelGpxVH holder) {
|
private void updateSaveButton(final TravelGpxVH holder) {
|
||||||
|
|
Loading…
Reference in a new issue