Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit e8f6d6b

Browse files
committed
Added bitmaploader interface
1 parent 3021436 commit e8f6d6b

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
* Created by thijs on 08-06-15.
2323
*/
2424
public class ScrollingImageView extends View {
25+
public static ScrollingImageViewBitmapLoader BITMAP_LOADER = new ScrollingImageViewBitmapLoader() {
26+
@Override
27+
public Bitmap loadBitmap(Context context, int resourceId) {
28+
return BitmapFactory.decodeResource(context.getResources(), resourceId);
29+
}
30+
};
31+
2532
private List<Bitmap> bitmaps;
2633
private float speed;
2734
private int[] scene;
@@ -65,7 +72,7 @@ public ScrollingImageView(Context context, AttributeSet attrs) {
6572
multiplier = Math.max(1, randomness[i]);
6673
}
6774

68-
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), typedArray.getResourceId(i, 0));
75+
Bitmap bitmap = BITMAP_LOADER.loadBitmap(getContext(), typedArray.getResourceId(i, 0));
6976
for (int m = 0; m < multiplier; m++) {
7077
bitmaps.add(bitmap);
7178
}
@@ -82,7 +89,7 @@ public ScrollingImageView(Context context, AttributeSet attrs) {
8289
typedArray.recycle();
8390
}
8491
} else if (type == TypedValue.TYPE_STRING) {
85-
final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), ta.getResourceId(R.styleable.ParallaxView_src, 0));
92+
final Bitmap bitmap = BITMAP_LOADER.loadBitmap(getContext(), ta.getResourceId(R.styleable.ParallaxView_src, 0));
8693
if (bitmap != null) {
8794
bitmaps = singletonList(bitmap);
8895
scene = new int[]{0};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.q42.android.scrollingimageview;
2+
3+
import android.content.Context;
4+
import android.graphics.Bitmap;
5+
6+
/**
7+
* Created by thijs on 22-03-16.
8+
*/
9+
public interface ScrollingImageViewBitmapLoader {
10+
Bitmap loadBitmap(Context context, int resourceId);
11+
}

0 commit comments

Comments
 (0)