Inferring nullity
This commit is contained in:
parent
54026bf6cc
commit
72e5b0fa91
@ -12,7 +12,7 @@ public abstract class NetworkReceiver extends BroadcastReceiver {
|
||||
public abstract void onConnectivityChange(boolean isConnected);
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(@NonNull Context context, Intent intent) {
|
||||
onConnectivityChange(isConnected(context));
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ abstract class BaseSuggestionsModel {
|
||||
* @return the cache file containing the suggestions
|
||||
*/
|
||||
@Nullable
|
||||
private InputStream downloadSuggestionsForQuery(@NonNull String query, String language) {
|
||||
private InputStream downloadSuggestionsForQuery(@NonNull String query, @NonNull String language) {
|
||||
String queryUrl = createQueryUrl(query, language);
|
||||
|
||||
try {
|
||||
@ -122,7 +122,7 @@ abstract class BaseSuggestionsModel {
|
||||
|
||||
private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.header("cache-control", "max-age=" + INTERVAL_DAY + ", max-stale=" + INTERVAL_DAY)
|
||||
|
@ -117,6 +117,7 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
|
||||
return mFilteredList.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
if (position > mFilteredList.size() || position < 0) {
|
||||
@ -138,14 +139,15 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
|
||||
mImage = (ImageView) view.findViewById(R.id.suggestionIcon);
|
||||
}
|
||||
|
||||
final ImageView mImage;
|
||||
final TextView mTitle;
|
||||
final TextView mUrl;
|
||||
@NonNull final ImageView mImage;
|
||||
@NonNull final TextView mTitle;
|
||||
@NonNull final TextView mUrl;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
public View getView(int position, @Nullable View convertView, ViewGroup parent) {
|
||||
SuggestionHolder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
@ -190,12 +192,13 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return new SearchFilter(this);
|
||||
}
|
||||
|
||||
private synchronized void publishResults(List<HistoryItem> list) {
|
||||
private synchronized void publishResults(@NonNull List<HistoryItem> list) {
|
||||
mFilteredList.clear();
|
||||
mFilteredList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
@ -315,8 +318,9 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
|
||||
mSuggestionsAdapter = suggestionsAdapter;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
protected FilterResults performFiltering(@Nullable CharSequence constraint) {
|
||||
FilterResults results = new FilterResults();
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
mSuggestionsAdapter.clearSuggestions();
|
||||
@ -359,8 +363,9 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
|
||||
return results;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CharSequence convertResultToString(Object resultValue) {
|
||||
public CharSequence convertResultToString(@NonNull Object resultValue) {
|
||||
return ((HistoryItem) resultValue).getUrl();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -17,7 +18,7 @@ public class MemoryLeakUtils {
|
||||
|
||||
private static final String TAG = MemoryLeakUtils.class.getSimpleName();
|
||||
|
||||
private static Method sFinishInputLocked = null;
|
||||
@Nullable private static Method sFinishInputLocked = null;
|
||||
|
||||
/**
|
||||
* Clears the mNextServedView and mServedView in
|
||||
|
@ -1,5 +1,7 @@
|
||||
package acr.browser.lightning.utils;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
public class Preconditions {
|
||||
/**
|
||||
* Ensure that an object is not null
|
||||
@ -8,7 +10,7 @@ public class Preconditions {
|
||||
*
|
||||
* @param object check nullness on this object.
|
||||
*/
|
||||
public static void checkNonNull(Object object) {
|
||||
public static void checkNonNull(@Nullable Object object) {
|
||||
if (object == null) {
|
||||
throw new RuntimeException("Object must not be null");
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public final class Utils {
|
||||
* @param userAgent the user agent of the browser.
|
||||
* @param contentDisposition the content description of the file.
|
||||
*/
|
||||
public static void downloadFile(final Activity activity, final PreferenceManager manager, final String url,
|
||||
public static void downloadFile(@NonNull final Activity activity, @NonNull final PreferenceManager manager, final String url,
|
||||
final String userAgent, final String contentDisposition) {
|
||||
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionsResultAction() {
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.TransitionDrawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
@ -17,7 +18,7 @@ public class BackgroundDrawable extends TransitionDrawable {
|
||||
* Create a new transition drawable with the specified list of layers. At least
|
||||
* 2 layers are required for this drawable to work properly.
|
||||
*/
|
||||
public BackgroundDrawable(Context context) {
|
||||
public BackgroundDrawable(@NonNull Context context) {
|
||||
super(new Drawable[]{new ColorDrawable(ContextCompat.getColor(context, R.color.transparent)),
|
||||
new ColorDrawable(ThemeUtils.getColor(context, R.attr.selectedBackground))});
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ public class LightningWebClient extends WebViewClient {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) {
|
||||
return shouldOverrideLoading(view, request.getUrl().toString()) || super.shouldOverrideUrlLoading(view, request);
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ public class LightningWebClient extends WebViewClient {
|
||||
return shouldOverrideLoading(view, url) || super.shouldOverrideUrlLoading(view, url);
|
||||
}
|
||||
|
||||
private boolean shouldOverrideLoading(WebView view, String url) {
|
||||
private boolean shouldOverrideLoading(@NonNull WebView view, @NonNull String url) {
|
||||
// Check if configured proxy is available
|
||||
if (!mProxyUtils.isProxyReady(mActivity)) {
|
||||
// User has been notified
|
||||
|
@ -1,6 +1,7 @@
|
||||
package acr.browser.lightning.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.AppCompatAutoCompleteTextView;
|
||||
import android.util.AttributeSet;
|
||||
@ -17,15 +18,15 @@ public class SearchView extends AppCompatAutoCompleteTextView {
|
||||
private boolean mIsBeingClicked;
|
||||
private long mTimePressed;
|
||||
|
||||
public SearchView(Context context) {
|
||||
public SearchView(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SearchView(Context context, AttributeSet attrs) {
|
||||
public SearchView(@NonNull Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SearchView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
public SearchView(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ public class SearchView extends AppCompatAutoCompleteTextView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
public boolean onTouchEvent(@NonNull MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mTimePressed = System.currentTimeMillis();
|
||||
|
Loading…
Reference in New Issue
Block a user