aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java')
-rw-r--r--library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java b/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java
index e7255a0..d4a54ce 100644
--- a/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java
+++ b/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/CompatDecoderFactory.java
@@ -10,36 +10,38 @@ import java.lang.reflect.InvocationTargetException;
* Compatibility factory to instantiate decoders with empty public constructors.
* @param <T> The base type of the decoder this factory will produce.
*/
+@SuppressWarnings("WeakerAccess")
public class CompatDecoderFactory<T> implements DecoderFactory<T> {
- private Class<? extends T> clazz;
- private Bitmap.Config bitmapConfig;
-
- /**
- * Construct a factory for the given class. This must have a default constructor.
- * @param clazz a class that implements {@link ImageDecoder} or {@link ImageRegionDecoder}.
- */
- public CompatDecoderFactory(@NonNull Class<? extends T> clazz) {
+
+ private Class<? extends T> clazz;
+ private Bitmap.Config bitmapConfig;
+
+ /**
+ * Construct a factory for the given class. This must have a default constructor.
+ * @param clazz a class that implements {@link ImageDecoder} or {@link ImageRegionDecoder}.
+ */
+ public CompatDecoderFactory(@NonNull Class<? extends T> clazz) {
this(clazz, null);
- }
-
- /**
- * Construct a factory for the given class. This must have a constructor that accepts a {@link Bitmap.Config} instance.
- * @param clazz a class that implements {@link ImageDecoder} or {@link ImageRegionDecoder}.
- * @param bitmapConfig bitmap configuration to be used when loading images.
- */
- public CompatDecoderFactory(@NonNull Class<? extends T> clazz, Bitmap.Config bitmapConfig) {
- this.clazz = clazz;
- this.bitmapConfig = bitmapConfig;
- }
-
- @Override
- public T make() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
- if (bitmapConfig == null) {
- return clazz.newInstance();
}
- else {
- Constructor<? extends T> ctor = clazz.getConstructor(Bitmap.Config.class);
- return ctor.newInstance(bitmapConfig);
+
+ /**
+ * Construct a factory for the given class. This must have a constructor that accepts a {@link Bitmap.Config} instance.
+ * @param clazz a class that implements {@link ImageDecoder} or {@link ImageRegionDecoder}.
+ * @param bitmapConfig bitmap configuration to be used when loading images.
+ */
+ public CompatDecoderFactory(@NonNull Class<? extends T> clazz, Bitmap.Config bitmapConfig) {
+ this.clazz = clazz;
+ this.bitmapConfig = bitmapConfig;
+ }
+
+ @Override
+ public T make() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
+ if (bitmapConfig == null) {
+ return clazz.newInstance();
+ } else {
+ Constructor<? extends T> ctor = clazz.getConstructor(Bitmap.Config.class);
+ return ctor.newInstance(bitmapConfig);
+ }
}
- }
+
}