diff options
author | George Mount <mount@google.com> | 2014-07-08 17:25:25 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2014-08-08 18:01:31 +0000 |
commit | fe361d2113b8f3c54797d7bd720ca739328bd7aa (patch) | |
tree | 635a0587afdea44a4016e64752c9ca1d20c9b8da /core/java/android/view/GhostView.java | |
parent | d18a1da18d1f92acc2669f936da00cd66657e44b (diff) | |
download | frameworks_base-fe361d2113b8f3c54797d7bd720ca739328bd7aa.zip frameworks_base-fe361d2113b8f3c54797d7bd720ca739328bd7aa.tar.gz frameworks_base-fe361d2113b8f3c54797d7bd720ca739328bd7aa.tar.bz2 |
Move shared elements to overlay when in a transition group.
Bug 15744995
Change-Id: Icf1ee603de23c7bb3bce3723cb24009e36f153d7
Diffstat (limited to 'core/java/android/view/GhostView.java')
-rw-r--r-- | core/java/android/view/GhostView.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/core/java/android/view/GhostView.java b/core/java/android/view/GhostView.java index 1aa8d99..a79838f 100644 --- a/core/java/android/view/GhostView.java +++ b/core/java/android/view/GhostView.java @@ -27,14 +27,13 @@ import android.graphics.Matrix; * @hide */ public class GhostView extends View { - private final Matrix mMatrix = new Matrix(); private final View mView; - private GhostView(View view, ViewGroup host) { + private GhostView(View view, ViewGroup host, Matrix matrix) { super(view.getContext()); mView = view; - setMatrix(host); mView.mGhostView = this; + mRenderNode.setAnimationMatrix(matrix); final ViewGroup parent = (ViewGroup) mView.getParent(); setLeft(0); setTop(0); @@ -49,17 +48,18 @@ public class GhostView extends View { protected void onDraw(Canvas canvas) { if (canvas instanceof HardwareCanvas) { HardwareCanvas hwCanvas = (HardwareCanvas) canvas; - int saveCount = hwCanvas.save(Canvas.MATRIX_SAVE_FLAG); - canvas.concat(mMatrix); mView.mRecreateDisplayList = true; RenderNode renderNode = mView.getDisplayList(); if (renderNode.isValid()) { hwCanvas.drawRenderNode(renderNode); } - hwCanvas.restoreToCount(saveCount); } } + public void setMatrix(Matrix matrix) { + mRenderNode.setAnimationMatrix(matrix); + } + @Override public void setVisibility(@Visibility int visibility) { super.setVisibility(visibility); @@ -79,18 +79,21 @@ public class GhostView extends View { setGhostedVisibility(View.VISIBLE); mView.mGhostView = null; final ViewGroup parent = (ViewGroup) mView.getParent(); - parent.mRecreateDisplayList = true; - parent.getDisplayList(); + if (parent != null) { + parent.mRecreateDisplayList = true; + parent.getDisplayList(); + } } - private void setMatrix(ViewGroup host) { - host.transformMatrixToLocal(mMatrix); - ViewGroup parent = (ViewGroup) mView.getParent(); - parent.transformMatrixToGlobal(mMatrix); - mMatrix.postTranslate(-parent.getScrollX(), -parent.getScrollY()); + public static void calculateMatrix(View view, ViewGroup host, Matrix matrix) { + ViewGroup parent = (ViewGroup) view.getParent(); + matrix.reset(); + parent.transformMatrixToGlobal(matrix); + matrix.preTranslate(-parent.getScrollX(), -parent.getScrollY()); + host.transformMatrixToLocal(matrix); } - public static GhostView addGhost(View view, ViewGroup viewGroup) { + public static GhostView addGhost(View view, ViewGroup viewGroup, Matrix matrix) { if (!(view.getParent() instanceof ViewGroup)) { throw new IllegalArgumentException("Ghosted views must be parented by a ViewGroup"); } @@ -105,12 +108,20 @@ public class GhostView extends View { } } if (ghostView == null) { - ghostView = new GhostView(view, (ViewGroup) overlayViewGroup.mHostView); + if (matrix == null) { + matrix = new Matrix(); + calculateMatrix(view, viewGroup, matrix); + } + ghostView = new GhostView(view, (ViewGroup) overlayViewGroup.mHostView, matrix); overlay.add(ghostView); } return ghostView; } + public static GhostView addGhost(View view, ViewGroup viewGroup) { + return addGhost(view, viewGroup, null); + } + public static void removeGhost(View view) { GhostView ghostView = view.mGhostView; if (ghostView != null) { |