From efd5780c3149a7f80ded6791749022ee30ff1b3b Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Tue, 18 Apr 2017 22:32:40 -0400 Subject: [PATCH] Annotating suggestions methods with nullable annotations --- .../acr/browser/lightning/search/BaseSuggestionsTask.java | 4 +++- .../acr/browser/lightning/search/DuckSuggestionsTask.java | 4 +++- .../acr/browser/lightning/search/GoogleSuggestionsTask.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java b/app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java index 11f54e0..76000bf 100644 --- a/app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java +++ b/app/src/main/java/acr/browser/lightning/search/BaseSuggestionsTask.java @@ -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 results) throws Exception; + protected abstract void parseResults(@NonNull FileInputStream inputStream, @NonNull List results) throws Exception; + @NonNull protected abstract String getEncoding(); BaseSuggestionsTask(@NonNull String query, diff --git a/app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java b/app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java index cec467f..7d4748d 100644 --- a/app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java +++ b/app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java @@ -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 results) throws Exception { + protected void parseResults(@NonNull FileInputStream inputStream, @NonNull List 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; diff --git a/app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java b/app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java index d68da9a..f9db50e 100644 --- a/app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java +++ b/app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java @@ -35,7 +35,7 @@ class GoogleSuggestionsTask extends BaseSuggestionsTask { } @Override - protected void parseResults(FileInputStream inputStream, List results) throws Exception { + protected void parseResults(@NonNull FileInputStream inputStream, @NonNull List 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;