OSDN Git Service

Only buildLayer() on attached views
authorChet Haase <chet@google.com>
Sat, 14 Sep 2013 02:01:52 +0000 (19:01 -0700)
committerChet Haase <chet@google.com>
Sat, 14 Sep 2013 02:01:52 +0000 (19:01 -0700)
A recent change to ViewPropertyAnimator.withLayer() builds the layer
immediately after creating it. This works in general, but if the view
is not attached, buildLayer() throws an exception.

The fix is to ensure that the view is attached before calling buildLayer().

Issue #10750925 Dialer crashed and phone dropped while on call

Change-Id: I801c835a0f5cb81e159fe90c157c122cf2d0da01

core/java/android/view/ViewPropertyAnimator.java

index 107d2c6..67a94be 100644 (file)
@@ -702,7 +702,9 @@ public class ViewPropertyAnimator {
             @Override
             public void run() {
                 mView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-                mView.buildLayer();
+                if (mView.isAttachedToWindow()) {
+                    mView.buildLayer();
+                }
             }
         };
         final int currentLayerType = mView.getLayerType();