OSDN Git Service

Set the bounds on the drawable for ChangeBounds reparenting.
authorGeorge Mount <mount@google.com>
Mon, 19 Oct 2015 19:14:01 +0000 (12:14 -0700)
committerGeorge Mount <mount@google.com>
Mon, 19 Oct 2015 23:42:38 +0000 (23:42 +0000)
Bug 24993183

The bounds for the drawable weren't being set, so the
drawable was never drawn to the correct size.

Change-Id: I992951f28ee6fac2ce8752d2dc0e23f51d3cf584
(cherry picked from commit f2a3703696f5dc8b1a0d243051e0db65c2145452)

core/java/android/transition/ChangeBounds.java

index c82587b..6d1d893 100644 (file)
@@ -432,23 +432,24 @@ public class ChangeBounds extends Transition {
                 return anim;
             }
         } else {
-            int startX = (Integer) startValues.values.get(PROPNAME_WINDOW_X);
-            int startY = (Integer) startValues.values.get(PROPNAME_WINDOW_Y);
-            int endX = (Integer) endValues.values.get(PROPNAME_WINDOW_X);
-            int endY = (Integer) endValues.values.get(PROPNAME_WINDOW_Y);
+            sceneRoot.getLocationInWindow(tempLocation);
+            int startX = (Integer) startValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
+            int startY = (Integer) startValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
+            int endX = (Integer) endValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
+            int endY = (Integer) endValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
             // TODO: also handle size changes: check bounds and animate size changes
             if (startX != endX || startY != endY) {
-                sceneRoot.getLocationInWindow(tempLocation);
-                Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
-                        Bitmap.Config.ARGB_8888);
+                final int width = view.getWidth();
+                final int height = view.getHeight();
+                Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
                 Canvas canvas = new Canvas(bitmap);
                 view.draw(canvas);
                 final BitmapDrawable drawable = new BitmapDrawable(bitmap);
+                drawable.setBounds(startX, startY, startX + width, startY + height);
                 final float transitionAlpha = view.getTransitionAlpha();
                 view.setTransitionAlpha(0);
                 sceneRoot.getOverlay().add(drawable);
-                Path topLeftPath = getPathMotion().getPath(startX - tempLocation[0],
-                        startY - tempLocation[1], endX - tempLocation[0], endY - tempLocation[1]);
+                Path topLeftPath = getPathMotion().getPath(startX, startY, endX, endY);
                 PropertyValuesHolder origin = PropertyValuesHolder.ofObject(
                         DRAWABLE_ORIGIN_PROPERTY, null, topLeftPath);
                 ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(drawable, origin);