diff --git a/OsmAnd/res/drawable/wikivoyage_search_history_placeholder.xml b/OsmAnd/res/drawable/wikivoyage_search_history_placeholder.xml new file mode 100644 index 0000000000..5ecd952e4e --- /dev/null +++ b/OsmAnd/res/drawable/wikivoyage_search_history_placeholder.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml b/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml index b93920d87e..54e09eedc7 100644 --- a/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml +++ b/OsmAnd/res/drawable/wikivoyage_search_placeholder.xml @@ -1,6 +1,5 @@ - + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 9adcb32f6e..4677bed26c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -22,6 +22,7 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; import java.io.File; import java.util.ArrayList; @@ -146,6 +147,8 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen return; } + WikivoyageLocalDataHelper.getInstance(getMyApplication()).addToHistory(article); + contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index 6798676a59..f1dd0378b0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -18,7 +18,9 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; +import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; +import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.List; @@ -29,7 +31,9 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter items = new ArrayList<>(); @@ -41,11 +45,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter historyItems) { + this.items.clear(); + if (historyItems != null && !historyItems.isEmpty()) { + this.items.add(app.getString(R.string.shared_string_history)); + this.items.addAll(historyItems); + } + notifyDataSetChanged(); + } + public void setItems(@Nullable List items) { this.items.clear(); if (items != null && !items.isEmpty()) { @@ -110,6 +129,21 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter items) { + if (items == null || items.isEmpty()) { + adapter.setHistoryItems(WikivoyageLocalDataHelper + .getInstance(getMyApplication()).getAllHistory()); + } else { + adapter.setItems(items); + } + } + private void runSearch() { switchProgressBarVisibility(true); cancelled = false; @@ -141,7 +155,7 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment getMyApplication().runInUIThread(new Runnable() { public void run() { if (!isCancelled()) { - adapter.setItems(results); + setAdapterItems(results); switchProgressBarVisibility(false); } }