summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2014-07-08 17:25:25 -0700
committerGeorge Mount <mount@google.com>2014-08-08 18:01:31 +0000
commitfe361d2113b8f3c54797d7bd720ca739328bd7aa (patch)
tree635a0587afdea44a4016e64752c9ca1d20c9b8da /core/java/android/view
parentd18a1da18d1f92acc2669f936da00cd66657e44b (diff)
downloadframeworks_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')
-rw-r--r--core/java/android/view/GhostView.java41
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--core/java/android/view/ViewGroup.java2
3 files changed, 28 insertions, 17 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) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 8c2048d..11ebc9c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -19007,7 +19007,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @hide
*/
public void findNamedViews(Map<String, View> namedElements) {
- if (getVisibility() == VISIBLE) {
+ if (getVisibility() == VISIBLE || mGhostView != null) {
String transitionName = getTransitionName();
if (transitionName != null) {
namedElements.put(transitionName, this);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 77f4b90..7f15381 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -6123,7 +6123,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
/** @hide */
@Override
public void findNamedViews(Map<String, View> namedElements) {
- if (getVisibility() != VISIBLE) {
+ if (getVisibility() != VISIBLE && mGhostView == null) {
return;
}
super.findNamedViews(namedElements);