Loading core/java/android/app/SharedElementCallback.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.os.Parcelable; import android.transition.TransitionUtils; import android.transition.TransitionUtils; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.ImageView.ScaleType; Loading Loading @@ -202,7 +203,8 @@ public abstract class SharedElementCallback { } else { } else { mTempMatrix.set(viewToGlobalMatrix); mTempMatrix.set(viewToGlobalMatrix); } } return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds); ViewGroup parent = (ViewGroup) sharedElement.getParent(); return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds, parent); } } /** /** Loading core/java/android/transition/TransitionUtils.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class TransitionUtils { ImageView copy = new ImageView(view.getContext()); ImageView copy = new ImageView(view.getContext()); copy.setScaleType(ImageView.ScaleType.CENTER_CROP); copy.setScaleType(ImageView.ScaleType.CENTER_CROP); Bitmap bitmap = createViewBitmap(view, matrix, bounds); Bitmap bitmap = createViewBitmap(view, matrix, bounds, sceneRoot); if (bitmap != null) { if (bitmap != null) { copy.setImageBitmap(bitmap); copy.setImageBitmap(bitmap); } } Loading Loading @@ -156,12 +156,19 @@ public class TransitionUtils { * returning. * returning. * @param bounds The bounds of the bitmap in the destination coordinate system (where the * @param bounds The bounds of the bitmap in the destination coordinate system (where the * view should be presented. Typically, this is matrix.mapRect(viewBounds); * 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. * @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) { public static Bitmap createViewBitmap(View view, Matrix matrix, RectF bounds, if (!view.isAttachedToWindow()) { ViewGroup sceneRoot) { final boolean addToOverlay = !view.isAttachedToWindow(); if (addToOverlay) { if (sceneRoot == null || !sceneRoot.isAttachedToWindow()) { return null; return null; } } sceneRoot.getOverlay().add(view); } Bitmap bitmap = null; Bitmap bitmap = null; int bitmapWidth = Math.round(bounds.width()); int bitmapWidth = Math.round(bounds.width()); int bitmapHeight = Math.round(bounds.height()); int bitmapHeight = Math.round(bounds.height()); Loading @@ -181,6 +188,9 @@ public class TransitionUtils { node.end(canvas); node.end(canvas); bitmap = ThreadedRenderer.createHardwareBitmap(node, bitmapWidth, bitmapHeight); bitmap = ThreadedRenderer.createHardwareBitmap(node, bitmapWidth, bitmapHeight); } } if (addToOverlay) { sceneRoot.getOverlay().remove(view); } return bitmap; return bitmap; } } Loading Loading
core/java/android/app/SharedElementCallback.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.os.Parcelable; import android.transition.TransitionUtils; import android.transition.TransitionUtils; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.ImageView.ScaleType; Loading Loading @@ -202,7 +203,8 @@ public abstract class SharedElementCallback { } else { } else { mTempMatrix.set(viewToGlobalMatrix); mTempMatrix.set(viewToGlobalMatrix); } } return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds); ViewGroup parent = (ViewGroup) sharedElement.getParent(); return TransitionUtils.createViewBitmap(sharedElement, mTempMatrix, screenBounds, parent); } } /** /** Loading
core/java/android/transition/TransitionUtils.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class TransitionUtils { ImageView copy = new ImageView(view.getContext()); ImageView copy = new ImageView(view.getContext()); copy.setScaleType(ImageView.ScaleType.CENTER_CROP); copy.setScaleType(ImageView.ScaleType.CENTER_CROP); Bitmap bitmap = createViewBitmap(view, matrix, bounds); Bitmap bitmap = createViewBitmap(view, matrix, bounds, sceneRoot); if (bitmap != null) { if (bitmap != null) { copy.setImageBitmap(bitmap); copy.setImageBitmap(bitmap); } } Loading Loading @@ -156,12 +156,19 @@ public class TransitionUtils { * returning. * returning. * @param bounds The bounds of the bitmap in the destination coordinate system (where the * @param bounds The bounds of the bitmap in the destination coordinate system (where the * view should be presented. Typically, this is matrix.mapRect(viewBounds); * 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. * @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) { public static Bitmap createViewBitmap(View view, Matrix matrix, RectF bounds, if (!view.isAttachedToWindow()) { ViewGroup sceneRoot) { final boolean addToOverlay = !view.isAttachedToWindow(); if (addToOverlay) { if (sceneRoot == null || !sceneRoot.isAttachedToWindow()) { return null; return null; } } sceneRoot.getOverlay().add(view); } Bitmap bitmap = null; Bitmap bitmap = null; int bitmapWidth = Math.round(bounds.width()); int bitmapWidth = Math.round(bounds.width()); int bitmapHeight = Math.round(bounds.height()); int bitmapHeight = Math.round(bounds.height()); Loading @@ -181,6 +188,9 @@ public class TransitionUtils { node.end(canvas); node.end(canvas); bitmap = ThreadedRenderer.createHardwareBitmap(node, bitmapWidth, bitmapHeight); bitmap = ThreadedRenderer.createHardwareBitmap(node, bitmapWidth, bitmapHeight); } } if (addToOverlay) { sceneRoot.getOverlay().remove(view); } return bitmap; return bitmap; } } Loading