Annotating suggestions methods with nullable annotations
This commit is contained in:
parent
79febae033
commit
efd5780c31
@ -44,10 +44,12 @@ abstract class BaseSuggestionsTask {
|
|||||||
@NonNull private final CacheControl mCacheControl;
|
@NonNull private final CacheControl mCacheControl;
|
||||||
@NonNull private String mQuery;
|
@NonNull private String mQuery;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
protected abstract String getQueryUrl(@NonNull String query, @NonNull String language);
|
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();
|
protected abstract String getEncoding();
|
||||||
|
|
||||||
BaseSuggestionsTask(@NonNull String query,
|
BaseSuggestionsTask(@NonNull String query,
|
||||||
|
@ -25,13 +25,14 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask {
|
|||||||
mSearchSubtitle = application.getString(R.string.suggestion);
|
mSearchSubtitle = application.getString(R.string.suggestion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected String getQueryUrl(@NonNull String query, @NonNull String language) {
|
protected String getQueryUrl(@NonNull String query, @NonNull String language) {
|
||||||
return "https://duckduckgo.com/ac/?q=" + query;
|
return "https://duckduckgo.com/ac/?q=" + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
String content = FileUtils.readStringFromFile(inputStream, ENCODING);
|
||||||
JSONArray jsonArray = new JSONArray(content);
|
JSONArray jsonArray = new JSONArray(content);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -47,6 +48,7 @@ final class DuckSuggestionsTask extends BaseSuggestionsTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected String getEncoding() {
|
protected String getEncoding() {
|
||||||
return ENCODING;
|
return ENCODING;
|
||||||
|
@ -35,7 +35,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
BufferedInputStream fileInput = new BufferedInputStream(inputStream);
|
||||||
XmlPullParser parser = getParser();
|
XmlPullParser parser = getParser();
|
||||||
parser.setInput(fileInput, ENCODING);
|
parser.setInput(fileInput, ENCODING);
|
||||||
@ -55,6 +55,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected String getEncoding() {
|
protected String getEncoding() {
|
||||||
return ENCODING;
|
return ENCODING;
|
||||||
|
Loading…
Reference in New Issue
Block a user