Skip to content

Commit

Permalink
Added bitmaploader interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuijten committed Mar 22, 2016
1 parent 3021436 commit e8f6d6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bitmap> bitmaps;
private float speed;
private int[] scene;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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};
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit e8f6d6b

Please sign in to comment.