diff --git a/instrumentation/src/androidTest/java/com/bumptech/glide/test/WaitModelLoader.java b/instrumentation/src/androidTest/java/com/bumptech/glide/test/WaitModelLoader.java index 358a542637..2c89c9227c 100644 --- a/instrumentation/src/androidTest/java/com/bumptech/glide/test/WaitModelLoader.java +++ b/instrumentation/src/androidTest/java/com/bumptech/glide/test/WaitModelLoader.java @@ -83,6 +83,7 @@ public static synchronized WaitModel waitOn(T model) { return new WaitModel<>(model); } + @NonNull @Override public ModelLoader, Data> build( MultiModelLoaderFactory multiFactory) { @@ -106,7 +107,7 @@ private static final class WaitFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { ConcurrencyHelper.waitOnLatch(toWaitOn); wrapped.loadData(priority, callback); } diff --git a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java index 2bbc438a97..dcac2f7688 100644 --- a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java +++ b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java @@ -38,7 +38,8 @@ public OkHttpStreamFetcher(OkHttpClient client, GlideUrl url) { } @Override - public void loadData(Priority priority, final DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull final DataCallback callback) { Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl()); for (Map.Entry headerEntry : url.getHeaders().entrySet()) { String key = headerEntry.getKey(); diff --git a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpUrlLoader.java b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpUrlLoader.java index c5374ba686..174c446f2a 100644 --- a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpUrlLoader.java +++ b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpUrlLoader.java @@ -1,5 +1,6 @@ package com.bumptech.glide.integration.okhttp; +import android.support.annotation.NonNull; import com.bumptech.glide.load.Options; import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.load.model.ModelLoader; @@ -25,14 +26,14 @@ public OkHttpUrlLoader(OkHttpClient client) { } @Override - public boolean handles(GlideUrl url) { + public boolean handles(@NonNull GlideUrl url) { return true; } @SuppressWarnings("deprecation") @Override - public LoadData buildLoadData(GlideUrl model, int width, int height, - Options options) { + public LoadData buildLoadData(@NonNull GlideUrl model, int width, int height, + @NonNull Options options) { return new LoadData<>(model, new OkHttpStreamFetcher(client, model)); } @@ -70,6 +71,7 @@ public Factory(OkHttpClient client) { this.client = client; } + @NonNull @SuppressWarnings("deprecation") @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { diff --git a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java index 7ffd81db6c..7855929053 100644 --- a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java +++ b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpStreamFetcher.java @@ -22,8 +22,7 @@ /** * Fetches an {@link InputStream} using the okhttp library. */ -public class OkHttpStreamFetcher implements DataFetcher, - okhttp3.Callback { +public class OkHttpStreamFetcher implements DataFetcher, okhttp3.Callback { private static final String TAG = "OkHttpFetcher"; private final Call.Factory client; private final GlideUrl url; @@ -40,7 +39,8 @@ public OkHttpStreamFetcher(Call.Factory client, GlideUrl url) { } @Override - public void loadData(Priority priority, final DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull final DataCallback callback) { Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl()); for (Map.Entry headerEntry : url.getHeaders().entrySet()) { String key = headerEntry.getKey(); diff --git a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyStreamFetcher.java b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyStreamFetcher.java index f43ff78252..97348ecc6e 100644 --- a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyStreamFetcher.java +++ b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyStreamFetcher.java @@ -2,7 +2,6 @@ import android.support.annotation.NonNull; import android.util.Log; -import com.android.volley.AuthFailureError; import com.android.volley.NetworkResponse; import com.android.volley.Request; import com.android.volley.RequestQueue; @@ -51,7 +50,8 @@ public VolleyStreamFetcher(RequestQueue requestQueue, GlideUrl url, } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { request = requestFactory.create(url.toStringUrl(), callback, glideToVolleyPriority(priority), url.getHeaders()); requestQueue.add(request); @@ -82,7 +82,7 @@ public DataSource getDataSource() { return DataSource.REMOTE; } - private static Request.Priority glideToVolleyPriority(Priority priority) { + private static Request.Priority glideToVolleyPriority(@NonNull Priority priority) { switch (priority) { case LOW: return Request.Priority.LOW; @@ -119,7 +119,7 @@ public GlideRequest(String url, DataCallback callback, Prio } @Override - public Map getHeaders() throws AuthFailureError { + public Map getHeaders() { return headers; } diff --git a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyUrlLoader.java b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyUrlLoader.java index d64a47d409..a5ceda30a9 100644 --- a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyUrlLoader.java +++ b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyUrlLoader.java @@ -77,6 +77,7 @@ public Factory(RequestQueue requestQueue, VolleyRequestFactory requestFactory) { this.requestQueue = requestQueue; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory factory) { return new VolleyUrlLoader(requestQueue, requestFactory); diff --git a/library/src/main/java/com/bumptech/glide/Registry.java b/library/src/main/java/com/bumptech/glide/Registry.java index 41e4c84327..49d31b6f7a 100644 --- a/library/src/main/java/com/bumptech/glide/Registry.java +++ b/library/src/main/java/com/bumptech/glide/Registry.java @@ -398,8 +398,9 @@ public Registry register(@NonNull ImageHeaderParser parser) { * {@link java.io.FileDescriptor}). */ @NonNull - public Registry append(Class modelClass, Class dataClass, - ModelLoaderFactory factory) { + public Registry append( + @NonNull Class modelClass, @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { modelLoaderRegistry.append(modelClass, dataClass, factory); return this; } @@ -428,8 +429,9 @@ public Registry append(Class modelClass, Class dataCl * {@link java.io.FileDescriptor}). */ @NonNull - public Registry prepend(Class modelClass, Class dataClass, - ModelLoaderFactory factory) { + public Registry prepend( + @NonNull Class modelClass, @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { modelLoaderRegistry.prepend(modelClass, dataClass, factory); return this; } @@ -459,9 +461,9 @@ public Registry prepend(Class modelClass, Class dataC */ @NonNull public Registry replace( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { modelLoaderRegistry.replace(modelClass, dataClass, factory); return this; } @@ -518,7 +520,7 @@ private List @Nullable public List> getRegisteredResourceClasses( - Class modelClass, @NonNull Class resourceClass, + @NonNull Class modelClass, @NonNull Class resourceClass, @NonNull Class transcodeClass) { List> result = modelToResourceClassCache.get(modelClass, resourceClass); @@ -597,11 +599,12 @@ public List getImageHeaderParsers() { // Never serialized by Glide. @SuppressWarnings("serial") public static class NoModelLoaderAvailableException extends MissingComponentException { - public NoModelLoaderAvailableException(Object model) { + public NoModelLoaderAvailableException(@NonNull Object model) { super("Failed to find any ModelLoaders for model: " + model); } - public NoModelLoaderAvailableException(Class modelClass, Class dataClass) { + public NoModelLoaderAvailableException(@NonNull Class modelClass, + @NonNull Class dataClass) { super("Failed to find any ModelLoaders for model: " + modelClass + " and data: " + dataClass); } } @@ -612,7 +615,7 @@ public NoModelLoaderAvailableException(Class modelClass, Class dataClass) // Never serialized by Glide. @SuppressWarnings("serial") public static class NoResultEncoderAvailableException extends MissingComponentException { - public NoResultEncoderAvailableException(Class resourceClass) { + public NoResultEncoderAvailableException(@NonNull Class resourceClass) { super("Failed to find result encoder for resource class: " + resourceClass); } } @@ -623,7 +626,7 @@ public NoResultEncoderAvailableException(Class resourceClass) { // Never serialized by Glide. @SuppressWarnings("serial") public static class NoSourceEncoderAvailableException extends MissingComponentException { - public NoSourceEncoderAvailableException(Class dataClass) { + public NoSourceEncoderAvailableException(@NonNull Class dataClass) { super("Failed to find source encoder for data class: " + dataClass); } } @@ -634,7 +637,7 @@ public NoSourceEncoderAvailableException(Class dataClass) { // Never serialized by Glide. @SuppressWarnings("serial") public static class MissingComponentException extends RuntimeException { - public MissingComponentException(String message) { + public MissingComponentException(@NonNull String message) { super(message); } } diff --git a/library/src/main/java/com/bumptech/glide/load/data/AssetPathFetcher.java b/library/src/main/java/com/bumptech/glide/load/data/AssetPathFetcher.java index 863ee034b4..f21eb6c646 100644 --- a/library/src/main/java/com/bumptech/glide/load/data/AssetPathFetcher.java +++ b/library/src/main/java/com/bumptech/glide/load/data/AssetPathFetcher.java @@ -27,7 +27,7 @@ public AssetPathFetcher(AssetManager assetManager, String assetPath) { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { data = loadResource(assetManager, assetPath); } catch (IOException e) { diff --git a/library/src/main/java/com/bumptech/glide/load/data/DataFetcher.java b/library/src/main/java/com/bumptech/glide/load/data/DataFetcher.java index 9889eaf06f..4a1674fd90 100644 --- a/library/src/main/java/com/bumptech/glide/load/data/DataFetcher.java +++ b/library/src/main/java/com/bumptech/glide/load/data/DataFetcher.java @@ -39,7 +39,7 @@ interface DataCallback { * * @param e a non-null {@link Exception} indicating why the load failed. */ - void onLoadFailed(Exception e); + void onLoadFailed(@NonNull Exception e); } /** @@ -63,7 +63,7 @@ interface DataCallback { * @param callback The callback to use when the request is complete * @see #cleanup() where the data retuned will be cleaned up */ - void loadData(Priority priority, DataCallback callback); + void loadData(@NonNull Priority priority, @NonNull DataCallback callback); /** * Cleanup or recycle any resources used by this data fetcher. This method will be called in a diff --git a/library/src/main/java/com/bumptech/glide/load/data/HttpUrlFetcher.java b/library/src/main/java/com/bumptech/glide/load/data/HttpUrlFetcher.java index 0649266988..d150608b48 100644 --- a/library/src/main/java/com/bumptech/glide/load/data/HttpUrlFetcher.java +++ b/library/src/main/java/com/bumptech/glide/load/data/HttpUrlFetcher.java @@ -48,7 +48,8 @@ public HttpUrlFetcher(GlideUrl glideUrl, int timeout) { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { long startTime = LogTime.getLogTime(); final InputStream result; try { diff --git a/library/src/main/java/com/bumptech/glide/load/data/LocalUriFetcher.java b/library/src/main/java/com/bumptech/glide/load/data/LocalUriFetcher.java index cb77e05ea8..68ee753057 100644 --- a/library/src/main/java/com/bumptech/glide/load/data/LocalUriFetcher.java +++ b/library/src/main/java/com/bumptech/glide/load/data/LocalUriFetcher.java @@ -38,7 +38,8 @@ public LocalUriFetcher(ContentResolver contentResolver, Uri uri) { } @Override - public final void loadData(Priority priority, DataCallback callback) { + public final void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { try { data = loadResource(uri, contentResolver); } catch (FileNotFoundException e) { diff --git a/library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbFetcher.java b/library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbFetcher.java index 3ab7f6a54e..3b90b0a6bf 100644 --- a/library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbFetcher.java +++ b/library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbFetcher.java @@ -52,7 +52,8 @@ private static ThumbFetcher build(Context context, Uri uri, ThumbnailQuery query } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { try { inputStream = openThumbInputStream(); } catch (FileNotFoundException e) { @@ -117,11 +118,11 @@ static class VideoThumbnailQuery implements ThumbnailQuery { } private static final String[] PATH_PROJECTION = { - MediaStore.Video.Thumbnails.DATA + MediaStore.Video.Thumbnails.DATA }; private static final String PATH_SELECTION = MediaStore.Video.Thumbnails.KIND + " = " + MediaStore.Video.Thumbnails.MINI_KIND - + " AND " + MediaStore.Video.Thumbnails.VIDEO_ID + " = ?"; + + " AND " + MediaStore.Video.Thumbnails.VIDEO_ID + " = ?"; @Override public Cursor query(Uri uri) { @@ -145,11 +146,11 @@ static class ImageThumbnailQuery implements ThumbnailQuery { } private static final String[] PATH_PROJECTION = { - MediaStore.Images.Thumbnails.DATA, + MediaStore.Images.Thumbnails.DATA, }; private static final String PATH_SELECTION = MediaStore.Images.Thumbnails.KIND + " = " + MediaStore.Images.Thumbnails.MINI_KIND - + " AND " + MediaStore.Images.Thumbnails.IMAGE_ID + " = ?"; + + " AND " + MediaStore.Images.Thumbnails.IMAGE_ID + " = ?"; @Override public Cursor query(Uri uri) { diff --git a/library/src/main/java/com/bumptech/glide/load/engine/DataCacheGenerator.java b/library/src/main/java/com/bumptech/glide/load/engine/DataCacheGenerator.java index 2eb478ee31..0972f30ad5 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/DataCacheGenerator.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/DataCacheGenerator.java @@ -1,5 +1,6 @@ package com.bumptech.glide.load.engine; +import android.support.annotation.NonNull; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.Key; import com.bumptech.glide.load.data.DataFetcher; @@ -92,7 +93,7 @@ public void onDataReady(Object data) { } @Override - public void onLoadFailed(Exception e) { + public void onLoadFailed(@NonNull Exception e) { cb.onDataFetcherFailed(sourceKey, e, loadData.fetcher, DataSource.DATA_DISK_CACHE); } } diff --git a/library/src/main/java/com/bumptech/glide/load/engine/ResourceCacheGenerator.java b/library/src/main/java/com/bumptech/glide/load/engine/ResourceCacheGenerator.java index 43a446f590..537da858a9 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/ResourceCacheGenerator.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/ResourceCacheGenerator.java @@ -1,5 +1,6 @@ package com.bumptech.glide.load.engine; +import android.support.annotation.NonNull; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.Key; import com.bumptech.glide.load.Transformation; @@ -110,7 +111,7 @@ public void onDataReady(Object data) { } @Override - public void onLoadFailed(Exception e) { + public void onLoadFailed(@NonNull Exception e) { cb.onDataFetcherFailed(currentKey, e, loadData.fetcher, DataSource.RESOURCE_DISK_CACHE); } } diff --git a/library/src/main/java/com/bumptech/glide/load/engine/SourceGenerator.java b/library/src/main/java/com/bumptech/glide/load/engine/SourceGenerator.java index f95ea8ca2a..5a57b971be 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/SourceGenerator.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/SourceGenerator.java @@ -1,5 +1,6 @@ package com.bumptech.glide.load.engine; +import android.support.annotation.NonNull; import android.util.Log; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.Encoder; @@ -114,7 +115,7 @@ public void onDataReady(Object data) { } @Override - public void onLoadFailed(Exception e) { + public void onLoadFailed(@NonNull Exception e) { cb.onDataFetcherFailed(originalKey, e, loadData.fetcher, loadData.fetcher.getDataSource()); } diff --git a/library/src/main/java/com/bumptech/glide/load/model/AssetUriLoader.java b/library/src/main/java/com/bumptech/glide/load/model/AssetUriLoader.java index f8af6151b0..9eea06323f 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/AssetUriLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/AssetUriLoader.java @@ -67,6 +67,7 @@ public StreamFactory(AssetManager assetManager) { this.assetManager = assetManager; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new AssetUriLoader<>(assetManager, this); @@ -96,6 +97,7 @@ public FileDescriptorFactory(AssetManager assetManager) { this.assetManager = assetManager; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new AssetUriLoader<>(assetManager, this); diff --git a/library/src/main/java/com/bumptech/glide/load/model/ByteArrayLoader.java b/library/src/main/java/com/bumptech/glide/load/model/ByteArrayLoader.java index 54d80326ce..42b17bf235 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ByteArrayLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ByteArrayLoader.java @@ -56,7 +56,7 @@ private static class Fetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { Data result = converter.convert(model); callback.onDataReady(result); } @@ -90,6 +90,7 @@ public DataSource getDataSource() { */ public static class ByteBufferFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ByteArrayLoader<>(new Converter() { @@ -116,6 +117,7 @@ public void teardown() { */ public static class StreamFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ByteArrayLoader<>(new Converter() { diff --git a/library/src/main/java/com/bumptech/glide/load/model/ByteBufferFileLoader.java b/library/src/main/java/com/bumptech/glide/load/model/ByteBufferFileLoader.java index bc0ac5dc5d..213c25ce18 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ByteBufferFileLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ByteBufferFileLoader.java @@ -35,6 +35,7 @@ public boolean handles(@NonNull File file) { */ public static class Factory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ByteBufferFileLoader(); @@ -57,7 +58,8 @@ private static class ByteBufferFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { ByteBuffer result; try { result = ByteBufferUtil.fromFile(file); diff --git a/library/src/main/java/com/bumptech/glide/load/model/DataUrlLoader.java b/library/src/main/java/com/bumptech/glide/load/model/DataUrlLoader.java index 8a47e2068e..6865bb818e 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/DataUrlLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/DataUrlLoader.java @@ -71,7 +71,7 @@ private static final class DataUriFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { data = reader.decode(dataUri); callback.onDataReady(data); @@ -150,6 +150,7 @@ public Class getDataClass() { }; } + @NonNull @Override public final ModelLoader build(MultiModelLoaderFactory multiFactory) { return new DataUrlLoader<>(opener); diff --git a/library/src/main/java/com/bumptech/glide/load/model/FileLoader.java b/library/src/main/java/com/bumptech/glide/load/model/FileLoader.java index 0e1b732b2f..f56f8bd589 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/FileLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/FileLoader.java @@ -63,7 +63,7 @@ private static class FileFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { data = opener.open(file); } catch (FileNotFoundException e) { @@ -116,6 +116,7 @@ public Factory(FileOpener opener) { this.opener = opener; } + @NonNull @Override public final ModelLoader build(MultiModelLoaderFactory multiFactory) { return new FileLoader<>(opener); diff --git a/library/src/main/java/com/bumptech/glide/load/model/MediaStoreFileLoader.java b/library/src/main/java/com/bumptech/glide/load/model/MediaStoreFileLoader.java index 32867b9283..6b36fb0ecb 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/MediaStoreFileLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/MediaStoreFileLoader.java @@ -53,7 +53,7 @@ private static class FilePathFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { Cursor cursor = context.getContentResolver().query(uri, PROJECTION, null /*selection*/, null /*selectionArgs*/, null /*sortOrder*/); @@ -109,6 +109,7 @@ public Factory(Context context) { this.context = context; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new MediaStoreFileLoader(context); diff --git a/library/src/main/java/com/bumptech/glide/load/model/ModelLoader.java b/library/src/main/java/com/bumptech/glide/load/model/ModelLoader.java index 30fde57fd8..2ef8de0dc4 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ModelLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ModelLoader.java @@ -47,11 +47,12 @@ class LoadData { public final List alternateKeys; public final DataFetcher fetcher; - public LoadData(Key sourceKey, DataFetcher fetcher) { + public LoadData(@NonNull Key sourceKey, @NonNull DataFetcher fetcher) { this(sourceKey, Collections.emptyList(), fetcher); } - public LoadData(Key sourceKey, List alternateKeys, DataFetcher fetcher) { + public LoadData(@NonNull Key sourceKey, @NonNull List alternateKeys, + @NonNull DataFetcher fetcher) { this.sourceKey = Preconditions.checkNotNull(sourceKey); this.alternateKeys = Preconditions.checkNotNull(alternateKeys); this.fetcher = Preconditions.checkNotNull(fetcher); diff --git a/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderFactory.java b/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderFactory.java index 19e1260195..3210771441 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderFactory.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderFactory.java @@ -1,6 +1,7 @@ package com.bumptech.glide.load.model; import android.content.Context; +import android.support.annotation.NonNull; /** * An interface for creating a {@link ModelLoader} for a given model type. Will be retained @@ -22,7 +23,8 @@ public interface ModelLoaderFactory { * {@link ModelLoader}s that this factory's {@link ModelLoader} may depend on * @return A new {@link ModelLoader} */ - ModelLoader build(MultiModelLoaderFactory multiFactory); + @NonNull + ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory); /** * A lifecycle method that will be called when this factory is about to replaced. diff --git a/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderRegistry.java b/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderRegistry.java index 37497b9911..ef11d7a211 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderRegistry.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ModelLoaderRegistry.java @@ -1,5 +1,7 @@ package com.bumptech.glide.load.model; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.util.Pools.Pool; import com.bumptech.glide.util.Synthetic; import java.util.ArrayList; @@ -19,51 +21,53 @@ public class ModelLoaderRegistry { private final MultiModelLoaderFactory multiModelLoaderFactory; private final ModelLoaderCache cache = new ModelLoaderCache(); - public ModelLoaderRegistry(Pool> throwableListPool) { + public ModelLoaderRegistry(@NonNull Pool> throwableListPool) { this(new MultiModelLoaderFactory(throwableListPool)); } - private ModelLoaderRegistry(MultiModelLoaderFactory multiModelLoaderFactory) { + private ModelLoaderRegistry(@NonNull MultiModelLoaderFactory multiModelLoaderFactory) { this.multiModelLoaderFactory = multiModelLoaderFactory; } public synchronized void append( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { multiModelLoaderFactory.append(modelClass, dataClass, factory); cache.clear(); } public synchronized void prepend( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { multiModelLoaderFactory.prepend(modelClass, dataClass, factory); cache.clear(); } - public synchronized void remove(Class modelClass, Class dataClass) { + public synchronized void remove(@NonNull Class modelClass, + @NonNull Class dataClass) { tearDown(multiModelLoaderFactory.remove(modelClass, dataClass)); cache.clear(); } public synchronized void replace( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { tearDown(multiModelLoaderFactory.replace(modelClass, dataClass, factory)); cache.clear(); } private void tearDown( - List> factories) { + @NonNull List> factories) { for (ModelLoaderFactory factory : factories) { factory.teardown(); } } - public synchronized List> getModelLoaders(A model) { + @NonNull + public synchronized List> getModelLoaders(@NonNull A model) { List> modelLoaders = getModelLoadersForClass(getClass(model)); int size = modelLoaders.size(); List> filteredLoaders = new ArrayList<>(size); @@ -77,16 +81,18 @@ private void tearDown( return filteredLoaders; } - public synchronized ModelLoader build(Class modelClass, - Class dataClass) { + public synchronized ModelLoader build(@NonNull Class modelClass, + @NonNull Class dataClass) { return multiModelLoaderFactory.build(modelClass, dataClass); } - public synchronized List> getDataClasses(Class modelClass) { + @NonNull + public synchronized List> getDataClasses(@NonNull Class modelClass) { return multiModelLoaderFactory.getDataClasses(modelClass); } - private List> getModelLoadersForClass(Class modelClass) { + @NonNull + private List> getModelLoadersForClass(@NonNull Class modelClass) { List> loaders = cache.get(modelClass); if (loaders == null) { loaders = Collections.unmodifiableList(multiModelLoaderFactory.build(modelClass)); @@ -95,8 +101,9 @@ public synchronized List> getDataClasses(Class modelClass) { return loaders; } + @NonNull @SuppressWarnings("unchecked") - private static Class getClass(A model) { + private static Class getClass(@NonNull A model) { return (Class) model.getClass(); } @@ -117,6 +124,7 @@ public void put(Class modelClass, List> loa } } + @Nullable @SuppressWarnings("unchecked") public List> get(Class modelClass) { Entry entry = (Entry) cachedModelLoaders.get(modelClass); diff --git a/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoader.java b/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoader.java index 84d97b2cac..684dc76b00 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoader.java @@ -29,8 +29,8 @@ class MultiModelLoader implements ModelLoader { private final List> modelLoaders; private final Pool> exceptionListPool; - MultiModelLoader(List> modelLoaders, - Pool> exceptionListPool) { + MultiModelLoader(@NonNull List> modelLoaders, + @NonNull Pool> exceptionListPool) { this.modelLoaders = modelLoaders; this.exceptionListPool = exceptionListPool; } @@ -82,7 +82,8 @@ static class MultiFetcher implements DataFetcher, DataCallback @Nullable private List exceptions; - MultiFetcher(List> fetchers, Pool> throwableListPool) { + MultiFetcher(@NonNull List> fetchers, + @NonNull Pool> throwableListPool) { this.throwableListPool = throwableListPool; Preconditions.checkNotEmpty(fetchers); this.fetchers = fetchers; @@ -90,7 +91,7 @@ static class MultiFetcher implements DataFetcher, DataCallback } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { this.priority = priority; this.callback = callback; exceptions = throwableListPool.acquire(); @@ -128,7 +129,7 @@ public DataSource getDataSource() { } @Override - public void onDataReady(Data data) { + public void onDataReady(@Nullable Data data) { if (data != null) { callback.onDataReady(data); } else { @@ -137,7 +138,7 @@ public void onDataReady(Data data) { } @Override - public void onLoadFailed(Exception e) { + public void onLoadFailed(@NonNull Exception e) { Preconditions.checkNotNull(exceptions).add(e); startNextOrFail(); } diff --git a/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoaderFactory.java b/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoaderFactory.java index eb903fab35..a286bc09da 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoaderFactory.java +++ b/library/src/main/java/com/bumptech/glide/load/model/MultiModelLoaderFactory.java @@ -28,53 +28,55 @@ public class MultiModelLoaderFactory { private final Set> alreadyUsedEntries = new HashSet<>(); private final Pool> throwableListPool; - public MultiModelLoaderFactory(Pool> throwableListPool) { + public MultiModelLoaderFactory(@NonNull Pool> throwableListPool) { this(throwableListPool, DEFAULT_FACTORY); } @VisibleForTesting - MultiModelLoaderFactory(Pool> throwableListPool, - Factory factory) { + MultiModelLoaderFactory(@NonNull Pool> throwableListPool, + @NonNull Factory factory) { this.throwableListPool = throwableListPool; this.factory = factory; } synchronized void append( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { add(modelClass, dataClass, factory, /*append=*/ true); } synchronized void prepend( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { add(modelClass, dataClass, factory, /*append=*/ false); } private void add( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory, + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory, boolean append) { Entry entry = new Entry<>(modelClass, dataClass, factory); entries.add(append ? entries.size() : 0, entry); } + @NonNull synchronized List> replace( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { List> removed = remove(modelClass, dataClass); append(modelClass, dataClass, factory); return removed; } + @NonNull synchronized List> remove( - Class modelClass, - Class dataClass) { + @NonNull Class modelClass, + @NonNull Class dataClass) { List> factories = new ArrayList<>(); for (Iterator> iterator = entries.iterator(); iterator.hasNext(); ) { Entry entry = iterator.next(); @@ -86,7 +88,8 @@ private void add( return factories; } - synchronized List> build(Class modelClass) { + @NonNull + synchronized List> build(@NonNull Class modelClass) { try { List> loaders = new ArrayList<>(); for (Entry entry : entries) { @@ -111,7 +114,8 @@ private void add( } } - synchronized List> getDataClasses(Class modelClass) { + @NonNull + synchronized List> getDataClasses(@NonNull Class modelClass) { List> result = new ArrayList<>(); for (Entry entry : entries) { if (!result.contains(entry.dataClass) && entry.handles(modelClass)) { @@ -121,8 +125,9 @@ synchronized List> getDataClasses(Class modelClass) { return result; } - public synchronized ModelLoader build(Class modelClass, - Class dataClass) { + @NonNull + public synchronized ModelLoader build(@NonNull Class modelClass, + @NonNull Class dataClass) { try { List> loaders = new ArrayList<>(); boolean ignoredAnyEntries = false; @@ -162,16 +167,19 @@ public synchronized ModelLoader build(Class mo } } + @NonNull @SuppressWarnings("unchecked") - private ModelLoaderFactory getFactory(Entry entry) { + private ModelLoaderFactory getFactory(@NonNull Entry entry) { return (ModelLoaderFactory) entry.factory; } + @NonNull @SuppressWarnings("unchecked") - private ModelLoader build(Entry entry) { + private ModelLoader build(@NonNull Entry entry) { return (ModelLoader) Preconditions.checkNotNull(entry.factory.build(this)); } + @NonNull @SuppressWarnings("unchecked") private static ModelLoader emptyModelLoader() { return (ModelLoader) EMPTY_MODEL_LOADER; @@ -183,32 +191,33 @@ private static class Entry { @Synthetic final ModelLoaderFactory factory; public Entry( - Class modelClass, - Class dataClass, - ModelLoaderFactory factory) { + @NonNull Class modelClass, + @NonNull Class dataClass, + @NonNull ModelLoaderFactory factory) { this.modelClass = modelClass; this.dataClass = dataClass; this.factory = factory; } - public boolean handles(Class modelClass, Class dataClass) { + public boolean handles(@NonNull Class modelClass, @NonNull Class dataClass) { return handles(modelClass) && this.dataClass.isAssignableFrom(dataClass); } - public boolean handles(Class modelClass) { + public boolean handles(@NonNull Class modelClass) { return this.modelClass.isAssignableFrom(modelClass); } } static class Factory { + @NonNull public MultiModelLoader build( - List> modelLoaders, Pool> throwableListPool) { + @NonNull List> modelLoaders, + @NonNull Pool> throwableListPool) { return new MultiModelLoader<>(modelLoaders, throwableListPool); } } private static class EmptyModelLoader implements ModelLoader { - @Synthetic EmptyModelLoader() { } diff --git a/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java b/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java index 7d1e491537..5ede18bb80 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java @@ -67,6 +67,7 @@ public StreamFactory(Resources resources) { this.resources = resources; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ResourceLoader<>(resources, multiFactory.build(Uri.class, InputStream.class)); @@ -90,6 +91,7 @@ public FileDescriptorFactory(Resources resources) { this.resources = resources; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ResourceLoader<>( @@ -113,6 +115,7 @@ public UriFactory(Resources resources) { this.resources = resources; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new ResourceLoader<>(resources, UnitModelLoader.getInstance()); diff --git a/library/src/main/java/com/bumptech/glide/load/model/StringLoader.java b/library/src/main/java/com/bumptech/glide/load/model/StringLoader.java index 85425979c5..26e2c95ecf 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/StringLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/StringLoader.java @@ -62,6 +62,7 @@ private static Uri toFileUri(String path) { */ public static class StreamFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new StringLoader<>(multiFactory.build(Uri.class, InputStream.class)); @@ -79,6 +80,7 @@ public void teardown() { public static class FileDescriptorFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new StringLoader<>(multiFactory.build(Uri.class, ParcelFileDescriptor.class)); diff --git a/library/src/main/java/com/bumptech/glide/load/model/UnitModelLoader.java b/library/src/main/java/com/bumptech/glide/load/model/UnitModelLoader.java index c59f2dd0aa..4ca9dd16a7 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/UnitModelLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/UnitModelLoader.java @@ -50,7 +50,8 @@ private static class UnitFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, + @NonNull DataCallback callback) { callback.onDataReady(resource); } @@ -100,6 +101,7 @@ public Factory() { // Intentionally empty. } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return UnitModelLoader.getInstance(); diff --git a/library/src/main/java/com/bumptech/glide/load/model/UriLoader.java b/library/src/main/java/com/bumptech/glide/load/model/UriLoader.java index 51277b4414..3b02a4902c 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/UriLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/UriLoader.java @@ -79,6 +79,7 @@ public DataFetcher build(Uri uri) { return new StreamLocalUriFetcher(contentResolver, uri); } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); @@ -108,6 +109,7 @@ public DataFetcher build(Uri uri) { return new FileDescriptorLocalUriFetcher(contentResolver, uri); } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); diff --git a/library/src/main/java/com/bumptech/glide/load/model/UrlUriLoader.java b/library/src/main/java/com/bumptech/glide/load/model/UrlUriLoader.java index 931ac86494..f51b8698f8 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/UrlUriLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/UrlUriLoader.java @@ -50,6 +50,7 @@ public boolean handles(@NonNull Uri uri) { */ public static class StreamFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new UrlUriLoader<>(multiFactory.build(GlideUrl.class, InputStream.class)); diff --git a/library/src/main/java/com/bumptech/glide/load/model/stream/HttpGlideUrlLoader.java b/library/src/main/java/com/bumptech/glide/load/model/stream/HttpGlideUrlLoader.java index 90bfbcc6fe..e149e19167 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/stream/HttpGlideUrlLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/stream/HttpGlideUrlLoader.java @@ -66,6 +66,7 @@ public boolean handles(@NonNull GlideUrl model) { public static class Factory implements ModelLoaderFactory { private final ModelCache modelCache = new ModelCache<>(500); + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new HttpGlideUrlLoader(modelCache); diff --git a/library/src/main/java/com/bumptech/glide/load/model/stream/HttpUriLoader.java b/library/src/main/java/com/bumptech/glide/load/model/stream/HttpUriLoader.java index 0567509267..7ff6639b20 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/stream/HttpUriLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/stream/HttpUriLoader.java @@ -44,6 +44,7 @@ public boolean handles(@NonNull Uri model) { */ public static class Factory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new HttpUriLoader(multiFactory.build(GlideUrl.class, InputStream.class)); diff --git a/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreImageThumbLoader.java b/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreImageThumbLoader.java index fdce945ade..aba0fe3cfa 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreImageThumbLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreImageThumbLoader.java @@ -51,6 +51,7 @@ public Factory(Context context) { this.context = context; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new MediaStoreImageThumbLoader(context); diff --git a/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreVideoThumbLoader.java b/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreVideoThumbLoader.java index a2862cf02c..678961ed0e 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreVideoThumbLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/stream/MediaStoreVideoThumbLoader.java @@ -65,6 +65,7 @@ public Factory(Context context) { this.context = context; } + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new MediaStoreVideoThumbLoader(context); diff --git a/library/src/main/java/com/bumptech/glide/load/model/stream/UrlLoader.java b/library/src/main/java/com/bumptech/glide/load/model/stream/UrlLoader.java index a2ae62eff4..c3995affaa 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/stream/UrlLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/stream/UrlLoader.java @@ -40,6 +40,7 @@ public boolean handles(@NonNull URL model) { */ public static class StreamFactory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new UrlLoader(multiFactory.build(GlideUrl.class, InputStream.class)); diff --git a/library/src/main/java/com/bumptech/glide/provider/ModelToResourceClassCache.java b/library/src/main/java/com/bumptech/glide/provider/ModelToResourceClassCache.java index 076661dfaa..ac417c13f6 100644 --- a/library/src/main/java/com/bumptech/glide/provider/ModelToResourceClassCache.java +++ b/library/src/main/java/com/bumptech/glide/provider/ModelToResourceClassCache.java @@ -1,5 +1,6 @@ package com.bumptech.glide.provider; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.util.ArrayMap; import com.bumptech.glide.util.MultiClassKey; @@ -16,7 +17,7 @@ public class ModelToResourceClassCache { new ArrayMap<>(); @Nullable - public List> get(Class modelClass, Class resourceClass) { + public List> get(@NonNull Class modelClass, @NonNull Class resourceClass) { MultiClassKey key = resourceClassKeyRef.getAndSet(null); if (key == null) { key = new MultiClassKey(modelClass, resourceClass); @@ -25,13 +26,14 @@ public List> get(Class modelClass, Class resourceClass) { } final List> result; synchronized (registeredResourceClassCache) { - result = registeredResourceClassCache.get(key); + result = registeredResourceClassCache.get(key); } resourceClassKeyRef.set(key); return result; } - public void put(Class modelClass, Class resourceClass, List> resourceClasses) { + public void put(@NonNull Class modelClass, @NonNull Class resourceClass, + @NonNull List> resourceClasses) { synchronized (registeredResourceClassCache) { registeredResourceClassCache .put(new MultiClassKey(modelClass, resourceClass), resourceClasses); diff --git a/library/src/test/java/com/bumptech/glide/load/model/DataUrlLoaderTest.java b/library/src/test/java/com/bumptech/glide/load/model/DataUrlLoaderTest.java index 6665f07202..f4b3e2d4af 100644 --- a/library/src/test/java/com/bumptech/glide/load/model/DataUrlLoaderTest.java +++ b/library/src/test/java/com/bumptech/glide/load/model/DataUrlLoaderTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Base64; import com.bumptech.glide.Priority; @@ -60,7 +61,7 @@ public class DataUrlLoaderTest { private Options options; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); DataUrlLoader.StreamFactory factory = new DataUrlLoader.StreamFactory(); options = new Options(); @@ -94,7 +95,7 @@ public void testDecode() throws IOException { } @Test - public void testDecodeInvalidScheme() throws IOException { + public void testDecodeInvalidScheme() { fetcher = dataUrlLoader.buildLoadData(INVALID_URL_WRONG_SCHEME1, -1, -1, options).fetcher; CallBack callback = new CallBack(); fetcher.loadData(Priority.HIGH, callback); @@ -102,7 +103,7 @@ public void testDecodeInvalidScheme() throws IOException { } @Test - public void testDecodeMissingComma() throws IOException { + public void testDecodeMissingComma() { fetcher = dataUrlLoader.buildLoadData(INVALID_URL_MISSING_COMMA, -1, -1, options).fetcher; CallBack callback = new CallBack(); fetcher.loadData(Priority.HIGH, callback); @@ -110,7 +111,7 @@ public void testDecodeMissingComma() throws IOException { } @Test - public void testDecodeWrongEncoding() throws IOException { + public void testDecodeWrongEncoding() { fetcher = dataUrlLoader.buildLoadData(INVALID_URL_WRONG_ENCODING, -1, -1, options).fetcher; CallBack callback = new CallBack(); fetcher.loadData(Priority.HIGH, callback); @@ -128,7 +129,7 @@ public void onDataReady(@Nullable Object data) { } @Override - public void onLoadFailed(Exception e) { + public void onLoadFailed(@NonNull Exception e) { this.exception = e; } } diff --git a/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrModelLoader.java b/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrModelLoader.java index 1d59551014..a2b3d2f6ef 100644 --- a/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrModelLoader.java +++ b/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrModelLoader.java @@ -26,6 +26,7 @@ public final class FlickrModelLoader extends BaseGlideUrlLoader { public static class Factory implements ModelLoaderFactory { private final ModelCache modelCache = new ModelCache<>(500); + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new FlickrModelLoader( diff --git a/samples/giphy/src/main/java/com/bumptech/glide/samples/giphy/GiphyModelLoader.java b/samples/giphy/src/main/java/com/bumptech/glide/samples/giphy/GiphyModelLoader.java index 5e4a00502e..a0163074e3 100644 --- a/samples/giphy/src/main/java/com/bumptech/glide/samples/giphy/GiphyModelLoader.java +++ b/samples/giphy/src/main/java/com/bumptech/glide/samples/giphy/GiphyModelLoader.java @@ -52,6 +52,7 @@ private static int getDifference(Api.GifImage gifImage, int width, int height) { * The default factory for {@link com.bumptech.glide.samples.giphy.GiphyModelLoader}s. */ public static final class Factory implements ModelLoaderFactory { + @NonNull @Override public ModelLoader build(MultiModelLoaderFactory multiFactory) { return new GiphyModelLoader(multiFactory.build(GlideUrl.class, InputStream.class));