Explorar el Código

Merge pull request #171 from tkskto/fix/viewshot-01

add null check
Gaëtan Renaudeau hace 6 años
padre
commit
6953261450
No account linked to committer's email address
Se han modificado 1 ficheros con 12 adiciones y 10 borrados
  1. 12
    10
      android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

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

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