Replace hardcode with constants
This commit is contained in:
parent
b4941e4637
commit
77c2260f94
1 changed files with 5 additions and 6 deletions
|
@ -11,7 +11,6 @@ import net.osmand.OsmAndCollator;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteStatement;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -22,7 +21,6 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TLongArrayList;
|
||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
|
||||
public class WikivoyageDbHelper {
|
||||
|
@ -80,13 +78,14 @@ public class WikivoyageDbHelper {
|
|||
|
||||
@NonNull
|
||||
public List<WikivoyageSearchResult> search(final String searchQuery) {
|
||||
|
||||
List<WikivoyageSearchResult> res = new ArrayList<>();
|
||||
SQLiteConnection conn = openConnection();
|
||||
if (conn != null) {
|
||||
try {
|
||||
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 + "%" });
|
||||
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 + "%"});
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
res.add(readSearchResult(cursor));
|
||||
|
@ -96,6 +95,7 @@ public class WikivoyageDbHelper {
|
|||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
List<WikivoyageSearchResult> list = new ArrayList<>(groupSearchResultsByCityId(res));
|
||||
Collections.sort(list, new Comparator<WikivoyageSearchResult>() {
|
||||
@Override
|
||||
|
@ -118,7 +118,6 @@ public class WikivoyageDbHelper {
|
|||
return list;
|
||||
}
|
||||
|
||||
|
||||
private Collection<WikivoyageSearchResult> groupSearchResultsByCityId(List<WikivoyageSearchResult> res) {
|
||||
String baseLng = application.getLanguage();
|
||||
TLongObjectHashMap<WikivoyageSearchResult> wikivoyage = new TLongObjectHashMap<>();
|
||||
|
|
Loading…
Reference in a new issue