diff --git a/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java index 62e72e7..a724a3b 100644 --- a/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java +++ b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java @@ -22,6 +22,13 @@ * Created by thijs on 08-06-15. */ public class ScrollingImageView extends View { + public static ScrollingImageViewBitmapLoader BITMAP_LOADER = new ScrollingImageViewBitmapLoader() { + @Override + public Bitmap loadBitmap(Context context, int resourceId) { + return BitmapFactory.decodeResource(context.getResources(), resourceId); + } + }; + private List bitmaps; private float speed; private int[] scene; @@ -65,7 +72,7 @@ public ScrollingImageView(Context context, AttributeSet attrs) { multiplier = Math.max(1, randomness[i]); } - Bitmap bitmap = BitmapFactory.decodeResource(getResources(), typedArray.getResourceId(i, 0)); + Bitmap bitmap = BITMAP_LOADER.loadBitmap(getContext(), typedArray.getResourceId(i, 0)); for (int m = 0; m < multiplier; m++) { bitmaps.add(bitmap); } @@ -82,7 +89,7 @@ public ScrollingImageView(Context context, AttributeSet attrs) { typedArray.recycle(); } } else if (type == TypedValue.TYPE_STRING) { - final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), ta.getResourceId(R.styleable.ParallaxView_src, 0)); + final Bitmap bitmap = BITMAP_LOADER.loadBitmap(getContext(), ta.getResourceId(R.styleable.ParallaxView_src, 0)); if (bitmap != null) { bitmaps = singletonList(bitmap); scene = new int[]{0}; diff --git a/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageViewBitmapLoader.java b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageViewBitmapLoader.java new file mode 100644 index 0000000..f8ebcc7 --- /dev/null +++ b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageViewBitmapLoader.java @@ -0,0 +1,11 @@ +package com.q42.android.scrollingimageview; + +import android.content.Context; +import android.graphics.Bitmap; + +/** + * Created by thijs on 22-03-16. + */ +public interface ScrollingImageViewBitmapLoader { + Bitmap loadBitmap(Context context, int resourceId); +}