diff options
| author | 2017-10-02 21:37:16 +0000 | |
|---|---|---|
| committer | 2017-10-02 21:37:16 +0000 | |
| commit | 085ef4ed9ad95d35ec0ff448451943903dfd4615 (patch) | |
| tree | 63bbcc8e7837674e9945e23a5d889f941c0ff865 | |
| parent | 13ab8c31429c905132b3e29242f4e4a2cd0ad6ed (diff) | |
| parent | 8e8e3eff082ea562deb8b9bccd05018d6b3e1f7f (diff) | |
Merge "Fix Transition test failure." into oc-mr1-dev am: dbd11d6c8b
am: 8e8e3eff08
Change-Id: Ifbffc328d5d356f77d668deb7104d7d73fc28bf2
| -rw-r--r-- | core/java/android/app/SharedElementCallback.java | 4 | ||||
| -rw-r--r-- | core/java/android/transition/TransitionUtils.java | 18 |
2 files changed, 17 insertions, 5 deletions
diff --git a/core/java/android/app/SharedElementCallback.java b/core/java/android/app/SharedElementCallback.java index 0d14a8d1e51f..80fb80588e55 100644 --- a/core/java/android/app/SharedElementCallback.java +++ b/core/java/android/app/SharedElementCallback.java @@ -27,6 +27,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.transition.TransitionUtils; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ImageView.ScaleType; @@ -202,7 +203,8 @@ public abstract class SharedElementCallback { } else { mTempMatrix.set(viewToGlobalMatrix); } - return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds); + ViewGroup parent = (ViewGroup) sharedElement.getParent(); + return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds, parent); } /** diff --git a/core/java/android/transition/TransitionUtils.java b/core/java/android/transition/TransitionUtils.java index 3306a5055297..084b79d58301 100644 --- a/core/java/android/transition/TransitionUtils.java +++ b/core/java/android/transition/TransitionUtils.java @@ -101,7 +101,7 @@ public class TransitionUtils { ImageView copy = new ImageView(view.getContext()); copy.setScaleType(ImageView.ScaleType.CENTER_CROP); - Bitmap bitmap = createViewBitmap(view, matrix, bounds); + Bitmap bitmap = createViewBitmap(view, matrix, bounds, sceneRoot); if (bitmap != null) { copy.setImageBitmap(bitmap); } @@ -156,11 +156,18 @@ public class TransitionUtils { * returning. * @param bounds The bounds of the bitmap in the destination coordinate system (where the * view should be presented. Typically, this is matrix.mapRect(viewBounds); + * @param sceneRoot A ViewGroup that is attached to the window to temporarily contain the view + * if it isn't attached to the window. * @return A bitmap of the given view or null if bounds has no width or height. */ - public static Bitmap createViewBitmap(View view, Matrix matrix, RectF bounds) { - if (!view.isAttachedToWindow()) { - return null; + public static Bitmap createViewBitmap(View view, Matrix matrix, RectF bounds, + ViewGroup sceneRoot) { + final boolean addToOverlay = !view.isAttachedToWindow(); + if (addToOverlay) { + if (sceneRoot == null || !sceneRoot.isAttachedToWindow()) { + return null; + } + sceneRoot.getOverlay().add(view); } Bitmap bitmap = null; int bitmapWidth = Math.round(bounds.width()); @@ -181,6 +188,9 @@ public class TransitionUtils { node.end(canvas); bitmap = ThreadedRenderer.createHardwareBitmap(node, bitmapWidth, bitmapHeight); } + if (addToOverlay) { + sceneRoot.getOverlay().remove(view); + } return bitmap; } |