Skip to content

Commit

Permalink
Merge pull request #11 from CliffBurton/patch-1
Browse files Browse the repository at this point in the history
Fixed "class could not be instantiated" bug
  • Loading branch information
tsuijten authored Nov 29, 2017
2 parents e8d1253 + e93ddb5 commit 0e9d335
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,31 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (canvas == null || bitmaps.isEmpty()) {
return;
}
if(!isInEditMode()) {
super.onDraw(canvas);
if (canvas == null || bitmaps.isEmpty()) {
return;
}

canvas.getClipBounds(clipBounds);
canvas.getClipBounds(clipBounds);

while (offset <= -getBitmap(arrayIndex).getWidth()) {
offset += getBitmap(arrayIndex).getWidth();
arrayIndex = (arrayIndex + 1) % scene.length;
}
while (offset <= -getBitmap(arrayIndex).getWidth()) {
offset += getBitmap(arrayIndex).getWidth();
arrayIndex = (arrayIndex + 1) % scene.length;
}

float left = offset;
for (int i = 0; left < clipBounds.width(); i++) {
Bitmap bitmap = getBitmap((arrayIndex + i) % scene.length);
int width = bitmap.getWidth();
canvas.drawBitmap(bitmap, getBitmapLeft(width, left), 0, null);
left += width;
}
float left = offset;
for (int i = 0; left < clipBounds.width(); i++) {
Bitmap bitmap = getBitmap((arrayIndex + i) % scene.length);
int width = bitmap.getWidth();
canvas.drawBitmap(bitmap, getBitmapLeft(width, left), 0, null);
left += width;
}

if (isStarted && speed != 0) {
offset -= abs(speed);
postInvalidateOnAnimation();
if (isStarted && speed != 0) {
offset -= abs(speed);
postInvalidateOnAnimation();
}
}
}

Expand Down

0 comments on commit 0e9d335

Please sign in to comment.