Browse Source

Annotating suggestions methods with nullable annotations

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

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

@ -44,10 +44,12 @@ abstract class BaseSuggestionsTask { @@ -44,10 +44,12 @@ abstract class BaseSuggestionsTask {
@NonNull private final CacheControl mCacheControl;
@NonNull private String mQuery;
@NonNull
protected abstract String getQueryUrl(@NonNull String query, @NonNull String language);
protected abstract void parseResults(FileInputStream inputStream, List<HistoryItem> results) throws Exception;
protected abstract void parseResults(@NonNull FileInputStream inputStream, @NonNull List<HistoryItem> results) throws Exception;
@NonNull
protected abstract String getEncoding();
BaseSuggestionsTask(@NonNull String query,

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

@ -25,13 +25,14 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask { @@ -25,13 +25,14 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask {
mSearchSubtitle = application.getString(R.string.suggestion);
}
@NonNull
@Override
protected String getQueryUrl(@NonNull String query, @NonNull String language) {
return "https://duckduckgo.com/ac/?q=" + query;
}
@Override
protected void parseResults(FileInputStream inputStream, List<HistoryItem> results) throws Exception {
protected void parseResults(@NonNull FileInputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
String content = FileUtils.readStringFromFile(inputStream, ENCODING);
JSONArray jsonArray = new JSONArray(content);
int counter = 0;
@ -47,6 +48,7 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask { @@ -47,6 +48,7 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask {
}
}
@NonNull
@Override
protected String getEncoding() {
return ENCODING;

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

@ -35,7 +35,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask { @@ -35,7 +35,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask {
}
@Override
protected void parseResults(FileInputStream inputStream, List<HistoryItem> results) throws Exception {
protected void parseResults(@NonNull FileInputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
BufferedInputStream fileInput = new BufferedInputStream(inputStream);
XmlPullParser parser = getParser();
parser.setInput(fileInput, ENCODING);
@ -55,6 +55,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask { @@ -55,6 +55,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask {
}
}
@NonNull
@Override
protected String getEncoding() {
return ENCODING;

Loading…
Cancel
Save