Don't manually encode spaces

This commit is contained in:
Anthony Restaino 2016-09-10 20:49:47 -04:00
parent 3e676920e1
commit 621ac7a574
3 changed files with 1 additions and 7 deletions

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
@ -53,7 +52,6 @@ public final class DuckSuggestionsTask {
private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName();
private static final Pattern SPACE_PATTERN = Pattern.compile(" ", Pattern.LITERAL);
private static final String ENCODING = "UTF-8";
private static final long INTERVAL_DAY = TimeUnit.DAYS.toMillis(1);
private static final String DEFAULT_LANGUAGE = "en";
@ -91,7 +89,6 @@ public final class DuckSuggestionsTask {
void run() {
List<HistoryItem> filter = new ArrayList<>(5);
try {
mQuery = SPACE_PATTERN.matcher(mQuery).replaceAll("+");
mQuery = URLEncoder.encode(mQuery, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();

View File

@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
@ -39,7 +38,6 @@ public class GoogleSuggestionsTask {
private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName();
private static final Pattern SPACE_PATTERN = Pattern.compile(" ", Pattern.LITERAL);
private static final String ENCODING = "ISO-8859-1";
private static final long INTERVAL_DAY = TimeUnit.DAYS.toMillis(1);
private static final String DEFAULT_LANGUAGE = "en";
@ -89,7 +87,6 @@ public class GoogleSuggestionsTask {
void run() {
List<HistoryItem> filter = new ArrayList<>(5);
try {
mQuery = SPACE_PATTERN.matcher(mQuery).replaceAll("+");
mQuery = URLEncoder.encode(mQuery, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();

View File

@ -332,7 +332,7 @@ public class Suggestions extends BaseAdapter implements Filterable {
mSuggestions.clearSuggestions();
return results;
}
String query = constraint.toString().toLowerCase(Locale.getDefault());
String query = constraint.toString().toLowerCase(Locale.getDefault()).trim();
if (mSuggestions.shouldRequestNetwork() && !SuggestionsManager.isRequestInProgress()) {
mSuggestions.getSuggestionsForQuery(query)