From f0374526a0bd26fd388795f2f12bba8cb825b199 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 2 Apr 2018 15:13:30 +0300 Subject: [PATCH] Add header to wikivoyage search list --- .../layout/wikivoyage_search_list_header.xml | 29 ++++++++ OsmAnd/res/values-large/sizes.xml | 2 + OsmAnd/res/values/sizes.xml | 2 + OsmAnd/res/values/strings.xml | 1 + .../search/SearchRecyclerViewAdapter.java | 74 ++++++++++++++----- .../WikivoyageSearchDialogFragment.java | 6 +- 6 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 OsmAnd/res/layout/wikivoyage_search_list_header.xml diff --git a/OsmAnd/res/layout/wikivoyage_search_list_header.xml b/OsmAnd/res/layout/wikivoyage_search_list_header.xml new file mode 100644 index 0000000000..849b7b545e --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_search_list_header.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index 1a4db9cba2..0f33324d93 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -193,4 +193,6 @@ 19dp 84dp + + 54dp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index e0084c2c1b..2774de8aab 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -267,4 +267,6 @@ 56dp 56dp + + 36dp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 9879b0d85d..3b46c67cf1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Result Use two digits longitude Travel Waypoints removed from map markers diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index 90f598529f..b8c58dc6e0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -17,11 +17,15 @@ import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; import java.util.ArrayList; import java.util.List; -public class SearchRecyclerViewAdapter extends RecyclerView.Adapter { +public class SearchRecyclerViewAdapter extends RecyclerView.Adapter { + private static final int HEADER_TYPE = 0; + private static final int ITEM_TYPE = 1; + + private OsmandApplication app; private IconsCache iconsCache; - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); private View.OnClickListener onItemClickListener; @@ -30,28 +34,49 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter items) { - if (items == null) { + if (items == null || items.isEmpty()) { this.items.clear(); } else { - this.items = items; + this.items.add(app.getString(R.string.shared_string_result)); + this.items.addAll(items); } notifyDataSetChanged(); } - static class ViewHolder extends RecyclerView.ViewHolder { + static class HeaderVH extends RecyclerView.ViewHolder { + + final TextView title; + + public HeaderVH(View itemView) { + super(itemView); + title = (TextView) itemView.findViewById(R.id.title); + } + } + + static class ItemVH extends RecyclerView.ViewHolder { final ImageView icon; final TextView title; @@ -80,7 +116,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter