Skip to content

Commit

Permalink
Code formatting and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davemorrissey committed Dec 12, 2017
1 parent 58a21f0 commit 43bf80b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,38 @@
* 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);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
* @param <T> the class of decoder that will be produced.
*/
public interface DecoderFactory<T> {
/**
* Produce a new instance of a decoder with type {@link T}.
* @return a new instance of your decoder.
* @throws IllegalAccessException if the factory class cannot be instantiated.
* @throws InstantiationException if the factory class cannot be instantiated.
* @throws NoSuchMethodException if the factory class cannot be instantiated.
* @throws InvocationTargetException if the factory class cannot be instantiated.
*/
T make() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException;

/**
* Produce a new instance of a decoder with type {@link T}.
* @return a new instance of your decoder.
* @throws IllegalAccessException if the factory class cannot be instantiated.
* @throws InstantiationException if the factory class cannot be instantiated.
* @throws NoSuchMethodException if the factory class cannot be instantiated.
* @throws InvocationTargetException if the factory class cannot be instantiated.
*/
T make() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.Uri;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public SkiaPooledImageRegionDecoder(Bitmap.Config bitmapConfig) {
* Controls logging of debug messages. All instances are affected.
* @param debug true to enable debug logging, false to disable.
*/
@Keep
@SuppressWarnings("unused")
public static void setDebug(boolean debug) {
SkiaPooledImageRegionDecoder.debug = debug;
}
Expand Down

0 comments on commit 43bf80b

Please sign in to comment.