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

Commit 0e9d335

Browse files
authored
Merge pull request #11 from CliffBurton/patch-1
Fixed "class could not be instantiated" bug
2 parents e8d1253 + e93ddb5 commit 0e9d335

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

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

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,31 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
115115

116116
@Override
117117
public void onDraw(Canvas canvas) {
118-
super.onDraw(canvas);
119-
if (canvas == null || bitmaps.isEmpty()) {
120-
return;
121-
}
118+
if(!isInEditMode()) {
119+
super.onDraw(canvas);
120+
if (canvas == null || bitmaps.isEmpty()) {
121+
return;
122+
}
122123

123-
canvas.getClipBounds(clipBounds);
124+
canvas.getClipBounds(clipBounds);
124125

125-
while (offset <= -getBitmap(arrayIndex).getWidth()) {
126-
offset += getBitmap(arrayIndex).getWidth();
127-
arrayIndex = (arrayIndex + 1) % scene.length;
128-
}
126+
while (offset <= -getBitmap(arrayIndex).getWidth()) {
127+
offset += getBitmap(arrayIndex).getWidth();
128+
arrayIndex = (arrayIndex + 1) % scene.length;
129+
}
129130

130-
float left = offset;
131-
for (int i = 0; left < clipBounds.width(); i++) {
132-
Bitmap bitmap = getBitmap((arrayIndex + i) % scene.length);
133-
int width = bitmap.getWidth();
134-
canvas.drawBitmap(bitmap, getBitmapLeft(width, left), 0, null);
135-
left += width;
136-
}
131+
float left = offset;
132+
for (int i = 0; left < clipBounds.width(); i++) {
133+
Bitmap bitmap = getBitmap((arrayIndex + i) % scene.length);
134+
int width = bitmap.getWidth();
135+
canvas.drawBitmap(bitmap, getBitmapLeft(width, left), 0, null);
136+
left += width;
137+
}
137138

138-
if (isStarted && speed != 0) {
139-
offset -= abs(speed);
140-
postInvalidateOnAnimation();
139+
if (isStarted && speed != 0) {
140+
offset -= abs(speed);
141+
postInvalidateOnAnimation();
142+
}
141143
}
142144
}
143145

0 commit comments

Comments
 (0)