Ver código fonte

add null check

takeshi kato 6 anos atrás
pai
commit
cf16f2389e

+ 12
- 10
android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java Ver arquivo

@@ -180,18 +180,20 @@ public class ViewShot implements UIBlock {
180 180
             if(child instanceof TextureView) {
181 181
                 ((TextureView) child).setOpaque(false);
182 182
                 childBitmapBuffer = ((TextureView) child).getBitmap(child.getWidth(), child.getHeight());
183
-                int left = child.getLeft();
184
-                int top = child.getTop();
185
-                View parentElem = (View)child.getParent();
186
-                while (parentElem != null) {
187
-                    if (parentElem == view) {
188
-                        break;
183
+                if (childBitmapBuffer != null) {
184
+                    int left = child.getLeft();
185
+                    int top = child.getTop();
186
+                    View parentElem = (View)child.getParent();
187
+                    while (parentElem != null) {
188
+                        if (parentElem == view) {
189
+                            break;
190
+                        }
191
+                        left += parentElem.getLeft();
192
+                        top += parentElem.getTop();
193
+                        parentElem = (View)parentElem.getParent();
189 194
                     }
190
-                    left += parentElem.getLeft();
191
-                    top += parentElem.getTop();
192
-                    parentElem = (View)parentElem.getParent();
195
+                    c.drawBitmap(childBitmapBuffer, left + child.getPaddingLeft(), top + child.getPaddingTop(), null);
193 196
                 }
194
-                c.drawBitmap(childBitmapBuffer, left + child.getPaddingLeft(),  top + child.getPaddingTop(), null);
195 197
             }
196 198
         }
197 199