OSDN Git Service

Fix NPE when requesting outsets for detached view.
authorFilip Gruszczynski <gruszczy@google.com>
Wed, 3 Jun 2015 17:32:26 +0000 (10:32 -0700)
committerThe Android Automerger <android-build@google.com>
Wed, 3 Jun 2015 20:13:08 +0000 (13:13 -0700)
Outsets are used during measure/layout pass, but this can be called on a
view that is not currently attached.

Bug: 21602590
Change-Id: I23e3acc45ca4bf7684d8913f839e29e8e9e94d78

core/java/android/view/View.java

index 37c8100..1e92a06 100644 (file)
@@ -7366,7 +7366,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
      * @hide
      */
     public void getOutsets(Rect outOutsetRect) {
-        outOutsetRect.set(mAttachInfo.mOutsets);
+        if (mAttachInfo != null) {
+            outOutsetRect.set(mAttachInfo.mOutsets);
+        } else {
+            outOutsetRect.setEmpty();
+        }
     }
 
     /**
@@ -14508,7 +14512,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
             }
         }
 
-        onDetachedFromWindow();
+        onDetachedFromWindows();
         onDetachedFromWindowInternal();
 
         InputMethodManager imm = InputMethodManager.peekInstance();