@@ -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