Show category if name is absent

This commit is contained in:
PavelRatushny 2017-11-23 16:21:16 +02:00
parent ef408d453b
commit 409de505f6

View file

@ -1,8 +1,12 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.system.Os; import android.system.Os;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -172,7 +176,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
} }
private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, int position) { private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, int position) {
holder.titleTextView.setText(OsmEditingPlugin.getName(osmEdit)); holder.titleTextView.setText(getTitle(osmEdit));
holder.descriptionTextView.setText(getDescription(osmEdit)); holder.descriptionTextView.setText(getDescription(osmEdit));
Drawable icon = getIcon(osmEdit); Drawable icon = getIcon(osmEdit);
if (icon != null) { if (icon != null) {
@ -227,6 +231,15 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
return items.size(); return items.size();
} }
private SpannableString getTitle(OsmPoint osmPoint) {
SpannableString title = new SpannableString(OsmEditingPlugin.getName(osmPoint));
if (TextUtils.isEmpty(title)) {
title = SpannableString.valueOf(getCategory(osmPoint));
title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0);
}
return title;
}
private Drawable getIcon(OsmPoint point) { private Drawable getIcon(OsmPoint point) {
if (point.getGroup() == OsmPoint.Group.POI) { if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point; OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point;
@ -279,6 +292,14 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
return true; return true;
} }
private String getCategory(OsmPoint point) {
String category = "";
if (point.getGroup() == OsmPoint.Group.POI) {
category = ((OpenstreetmapPoint) point).getEntity().getTag(EditPoiData.POI_TYPE_TAG);
}
return category;
}
private String getDescription(OsmPoint point) { private String getDescription(OsmPoint point) {
String action = ""; String action = "";
if (point.getAction() == OsmPoint.Action.CREATE) { if (point.getAction() == OsmPoint.Action.CREATE) {
@ -291,10 +312,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
action = getContext().getString(R.string.shared_string_edited); action = getContext().getString(R.string.shared_string_edited);
} }
String category = ""; String category = getCategory(point);
if (point.getGroup() == OsmPoint.Group.POI) {
category = ((OpenstreetmapPoint) point).getEntity().getTag(EditPoiData.POI_TYPE_TAG);
}
String comment = ""; String comment = "";
if (point.getGroup() == OsmPoint.Group.BUG) { if (point.getGroup() == OsmPoint.Group.BUG) {