Fix search

This commit is contained in:
Victor Shcherb 2018-03-30 13:25:12 +02:00
parent 89eaae55c3
commit 59ead8f7dc

View file

@ -11,6 +11,7 @@ import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import net.osmand.plus.api.SQLiteAPI.SQLiteStatement;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import gnu.trove.map.hash.TLongObjectHashMap; import gnu.trove.map.hash.TLongObjectHashMap;
@ -82,7 +83,7 @@ public class WikivoyageDbHelper {
SQLiteConnection conn = openConnection(); SQLiteConnection conn = openConnection();
if (conn != null) { if (conn != null) {
try { try {
String dbQuery = SEARCH_TABLE_SELECT + " WHERE " + SEARCH_COL_SEARCH_TERM + " LIKE ?"; String dbQuery = SEARCH_TABLE_SELECT + " WHERE city_id IN (select city_id from wikivoyage_search where search_term like ?)";
SQLiteCursor cursor = conn.rawQuery(dbQuery, new String[] { searchQuery + "%" }); SQLiteCursor cursor = conn.rawQuery(dbQuery, new String[] { searchQuery + "%" });
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
do { do {
@ -94,7 +95,7 @@ public class WikivoyageDbHelper {
conn.close(); conn.close();
} }
} }
List<WikivoyageSearchResult> list = new ArrayList(groupSearchResultsByCityId(res)); List<WikivoyageSearchResult> list = new ArrayList<>(groupSearchResultsByCityId(res));
Collections.sort(list, new Comparator<WikivoyageSearchResult>() { Collections.sort(list, new Comparator<WikivoyageSearchResult>() {