Format and refactor code in WikivoyageDbHelper
This commit is contained in:
parent
23e3ab2e14
commit
0706968dc1
1 changed files with 12 additions and 14 deletions
|
@ -2,6 +2,7 @@ package net.osmand.plus.wikivoyage.data;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
|
@ -61,8 +62,6 @@ public class WikivoyageDbHelper {
|
|||
private static final String SEARCH_COL_ARTICLE_TITLE = "article_title";
|
||||
private static final String SEARCH_COL_LANG = "lang";
|
||||
|
||||
;
|
||||
|
||||
private final OsmandApplication application;
|
||||
|
||||
private Collator collator;
|
||||
|
@ -79,12 +78,12 @@ public class WikivoyageDbHelper {
|
|||
String[] queries = searchQuery.replace('_', ' ').replace('/', ' ').split(" ");
|
||||
if (conn != null) {
|
||||
try {
|
||||
List<String> params = new ArrayList<String>();
|
||||
List<String> params = new ArrayList<>();
|
||||
String query = "SELECT distinct wa.city_id, wa.title, wa.lang, wa.is_part_of, wa.image_title " +
|
||||
"FROM wikivoyage_articles wa WHERE wa.city_id in " +
|
||||
" (SELECT city_id FROM wikivoyage_search WHERE search_term LIKE";
|
||||
for(int i = 0; i < queries.length; i++) {
|
||||
if(queries[i].trim().length() > 0) {
|
||||
for (String q : queries) {
|
||||
if (q.trim().length() > 0) {
|
||||
if (params.size() > 5) {
|
||||
// don't explode the query search much
|
||||
break;
|
||||
|
@ -94,8 +93,7 @@ public class WikivoyageDbHelper {
|
|||
} else {
|
||||
query += "?";
|
||||
}
|
||||
params.add(queries[i].trim() +"%");
|
||||
|
||||
params.add(q.trim() + "%");
|
||||
}
|
||||
}
|
||||
query += ") ";
|
||||
|
|
Loading…
Reference in a new issue