Add description (waypoint categories) in gpx menu item in AddTracksGroupBottomSheetDialogFragment
This commit is contained in:
parent
98654d45d5
commit
b0f47eb074
3 changed files with 55 additions and 8 deletions
|
@ -4,10 +4,10 @@
|
|||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
|
@ -19,15 +19,33 @@
|
|||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_polygom_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_text"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Berlin trip"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:visibility="gone"
|
||||
tools:text="Some description"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/number_count_text"
|
||||
|
|
|
@ -12,11 +12,13 @@ public class MapMarkersGroupViewHolder extends RecyclerView.ViewHolder {
|
|||
ImageView icon;
|
||||
TextView name;
|
||||
TextView numberCount;
|
||||
TextView description;
|
||||
|
||||
public MapMarkersGroupViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
name = itemView.findViewById(R.id.name_text);
|
||||
numberCount = itemView.findViewById(R.id.number_count_text);
|
||||
description = itemView.findViewById(R.id.description_text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TracksGroupsAdapter extends GroupsAdapter {
|
||||
|
||||
|
@ -29,6 +33,9 @@ public class TracksGroupsAdapter extends GroupsAdapter {
|
|||
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
markersGroupViewHolder.name.setText(gpx.getFile().getName().replace(".gpx", "").replace("/", " ").replace("_", " "));
|
||||
markersGroupViewHolder.numberCount.setText(String.valueOf(gpx.getAnalysis().wptPoints));
|
||||
String description = getDescription(gpx);
|
||||
markersGroupViewHolder.description.setVisibility(description == null ? View.GONE : View.VISIBLE);
|
||||
markersGroupViewHolder.description.setText(description);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +44,26 @@ public class TracksGroupsAdapter extends GroupsAdapter {
|
|||
return gpxFiles.size() + 1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getDescription(GpxDataItem item) {
|
||||
Set<String> categories = item.getAnalysis().wptCategoryNames;
|
||||
if (categories != null && !categories.isEmpty() && !(categories.size() == 1 && categories.contains(""))) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<String> it = categories.iterator();
|
||||
while (it.hasNext()) {
|
||||
String category = it.next();
|
||||
if (!category.equals("")) {
|
||||
sb.append(category);
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private GpxDataItem getItem(int position) {
|
||||
return gpxFiles.get(position - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue