Browse Source

Renaming task method

master
anthony restaino 8 years ago
parent
commit
491d872008
  1. 6
      app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java
  2. 4
      app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java
  3. 4
      app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java

6
app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java

@ -36,7 +36,7 @@ abstract class BaseSuggestionsTask { @@ -36,7 +36,7 @@ abstract class BaseSuggestionsTask {
static final int MAX_RESULTS = 5;
private static final long INTERVAL_DAY = TimeUnit.DAYS.toMillis(1);
private static final String DEFAULT_LANGUAGE = "en";
@NonNull private static final String DEFAULT_LANGUAGE = "en";
@Nullable private static String sLanguage;
@NonNull private final SuggestionsResult mResultCallback;
@NonNull private final Application mApplication;
@ -46,7 +46,7 @@ abstract class BaseSuggestionsTask { @@ -46,7 +46,7 @@ abstract class BaseSuggestionsTask {
@NonNull private String mQuery;
@NonNull
protected abstract String getQueryUrl(@NonNull String query, @NonNull String language);
protected abstract String createQueryUrl(@NonNull String query, @NonNull String language);
protected abstract void parseResults(@NonNull FileInputStream inputStream, @NonNull List<HistoryItem> results) throws Exception;
@ -113,7 +113,7 @@ abstract class BaseSuggestionsTask { @@ -113,7 +113,7 @@ abstract class BaseSuggestionsTask {
*/
@NonNull
private File downloadSuggestionsForQuery(@NonNull String query, String language, @NonNull Application app) {
String queryUrl = getQueryUrl(query, language);
String queryUrl = createQueryUrl(query, language);
File cacheFile = new File(app.getCacheDir(), queryUrl.hashCode() + SuggestionsAdapter.CACHE_FILE_TYPE);
if (System.currentTimeMillis() - INTERVAL_DAY < cacheFile.lastModified()) {
return cacheFile;

4
app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java

@ -15,7 +15,7 @@ import acr.browser.lightning.utils.FileUtils; @@ -15,7 +15,7 @@ import acr.browser.lightning.utils.FileUtils;
final class DuckSuggestionsTask extends BaseSuggestionsTask {
private static final String ENCODING = "UTF-8";
@NonNull private static final String ENCODING = "UTF-8";
@NonNull private final String mSearchSubtitle;
DuckSuggestionsTask(@NonNull String query,
@ -27,7 +27,7 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask { @@ -27,7 +27,7 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask {
@NonNull
@Override
protected String getQueryUrl(@NonNull String query, @NonNull String language) {
protected String createQueryUrl(@NonNull String query, @NonNull String language) {
return "https://duckduckgo.com/ac/?q=" + query;
}

4
app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java

@ -17,7 +17,7 @@ import acr.browser.lightning.database.HistoryItem; @@ -17,7 +17,7 @@ import acr.browser.lightning.database.HistoryItem;
class GoogleSuggestionsTask extends BaseSuggestionsTask {
private static final String ENCODING = "ISO-8859-1";
@NonNull private static final String ENCODING = "ISO-8859-1";
@Nullable private static XmlPullParser sXpp;
@NonNull private final String mSearchSubtitle;
@ -29,7 +29,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask { @@ -29,7 +29,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask {
}
@NonNull
protected String getQueryUrl(@NonNull String query, @NonNull String language) {
protected String createQueryUrl(@NonNull String query, @NonNull String language) {
return "https://suggestqueries.google.com/complete/search?output=toolbar&hl="
+ language + "&q=" + query;
}

Loading…
Cancel
Save