diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java index d2eba0e5cb..6f5601b99a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java @@ -60,12 +60,20 @@ public class WikivoyageDbHelper { private static final String SEARCH_COL_ARTICLE_TITLE = "article_title"; private static final String SEARCH_COL_LANG = "lang"; - private static final String SEARCH_TABLE_SELECT = "SELECT " + + private static final String SEARCH_QUERY = "SELECT " + SEARCH_COL_SEARCH_TERM + ", " + - SEARCH_COL_CITY_ID + ", " + + SEARCH_TABLE_NAME + "." + SEARCH_COL_CITY_ID + ", " + SEARCH_COL_ARTICLE_TITLE + ", " + - SEARCH_COL_LANG + - " FROM " + SEARCH_TABLE_NAME; + SEARCH_TABLE_NAME + "." + SEARCH_COL_LANG + ", " + + ARTICLES_COL_IS_PART_OF + + " FROM " + SEARCH_TABLE_NAME + + " JOIN " + ARTICLES_TABLE_NAME + + " ON " + SEARCH_TABLE_NAME + "." + SEARCH_COL_ARTICLE_TITLE + " = " + ARTICLES_TABLE_NAME + "." + ARTICLES_COL_TITLE + + " AND " + SEARCH_TABLE_NAME + "." + SEARCH_COL_LANG + " = " + ARTICLES_TABLE_NAME + "." + ARTICLES_COL_LANG + + " WHERE " + SEARCH_TABLE_NAME + "." + SEARCH_COL_CITY_ID + + " IN (SELECT " + SEARCH_TABLE_NAME + "." + SEARCH_COL_CITY_ID + + " FROM " + SEARCH_TABLE_NAME + + " WHERE " + SEARCH_COL_SEARCH_TERM + " LIKE ?)"; private final OsmandApplication application; @@ -82,10 +90,7 @@ public class WikivoyageDbHelper { SQLiteConnection conn = openConnection(); if (conn != null) { try { - String dbQuery = SEARCH_TABLE_SELECT + " WHERE " + SEARCH_COL_CITY_ID + - " IN (SELECT " + SEARCH_COL_CITY_ID + " FROM " + SEARCH_TABLE_NAME + - " WHERE " + SEARCH_COL_SEARCH_TERM + " LIKE ?)"; - SQLiteCursor cursor = conn.rawQuery(dbQuery, new String[]{searchQuery + "%"}); + SQLiteCursor cursor = conn.rawQuery(SEARCH_QUERY, new String[]{searchQuery + "%"}); if (cursor.moveToFirst()) { do { res.add(readSearchResult(cursor)); @@ -179,6 +184,7 @@ public class WikivoyageDbHelper { res.cityId = cursor.getLong(1); res.articleTitles.add(cursor.getString(2)); res.langs.add(cursor.getString(3)); + res.isPartOf = cursor.getString(4); return res; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java index ecabd84876..8ac59c2e12 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageSearchResult.java @@ -12,6 +12,7 @@ public class WikivoyageSearchResult implements Parcelable { long cityId; List articleTitles = new ArrayList<>(); List langs = new ArrayList<>(); + String isPartOf; WikivoyageSearchResult() { @@ -22,6 +23,7 @@ public class WikivoyageSearchResult implements Parcelable { cityId = in.readLong(); articleTitles = in.createStringArrayList(); langs = in.createStringArrayList(); + isPartOf = in.readString(); } public List getSearchTerms() { @@ -40,6 +42,10 @@ public class WikivoyageSearchResult implements Parcelable { return langs; } + public String getIsPartOf() { + return isPartOf; + } + @Override public int describeContents() { return 0; @@ -51,6 +57,7 @@ public class WikivoyageSearchResult implements Parcelable { dest.writeLong(cityId); dest.writeStringList(articleTitles); dest.writeStringList(langs); + dest.writeString(isPartOf); } public static final Creator CREATOR = new Creator() { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java index b2a9dc7ab2..df3299c8f9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/search/SearchRecyclerViewAdapter.java @@ -3,6 +3,7 @@ package net.osmand.plus.wikivoyage.search; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,6 +14,7 @@ import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; +import net.osmand.util.Algorithms; import java.util.ArrayList; import java.util.List; @@ -64,7 +66,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter