Annotating suggestions methods with nullable annotations

This commit is contained in:
anthony restaino 2017-04-18 22:32:40 -04:00
parent 79febae033
commit efd5780c31
3 changed files with 8 additions and 3 deletions

View File

@ -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,

View File

@ -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 {
}
}
@NonNull
@Override
protected String getEncoding() {
return ENCODING;

View File

@ -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 {
}
}
@NonNull
@Override
protected String getEncoding() {
return ENCODING;