summaryrefslogtreecommitdiffstats
path: root/core/java/android/transition/MoveImage.java
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2014-05-05 10:47:00 -0700
committerGeorge Mount <mount@google.com>2014-05-05 12:25:43 -0700
commit080443bcb63418245c2408500db735fece5e7083 (patch)
treee3875478b9c290a9b8501d464be6f03ccae3b86a /core/java/android/transition/MoveImage.java
parent973a1d27417d22add96d716bfce702a48543931b (diff)
downloadframeworks_base-080443bcb63418245c2408500db735fece5e7083.zip
frameworks_base-080443bcb63418245c2408500db735fece5e7083.tar.gz
frameworks_base-080443bcb63418245c2408500db735fece5e7083.tar.bz2
Add ImageView-specific shared element activity transition code.
Bug 14497858 Probably more than 50% of shared elements will be ImageViews and sharing the scale type and matrix between the two Activities will simplify shared element transitions. Also fixed MoveImage, which had a bug when the scale type was FIX_XY. Change-Id: Ic5548b4d1420ced12507c18edf76c9e50e27a929
Diffstat (limited to 'core/java/android/transition/MoveImage.java')
-rw-r--r--core/java/android/transition/MoveImage.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/core/java/android/transition/MoveImage.java b/core/java/android/transition/MoveImage.java
index e4c3939..183cdd2 100644
--- a/core/java/android/transition/MoveImage.java
+++ b/core/java/android/transition/MoveImage.java
@@ -125,7 +125,7 @@ public class MoveImage extends Transition {
Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
- if (!startMatrix.equals(endMatrix)) {
+ if (startMatrix != null && !startMatrix.equals(endMatrix)) {
changes.add(PropertyValuesHolder.ofObject(MatrixClippedDrawable.MATRIX_PROPERTY,
new MatrixEvaluator(), startMatrix, endMatrix));
}
@@ -230,7 +230,9 @@ public class MoveImage extends Transition {
private static void expandClip(Rect bounds, Matrix matrix, Rect clip, Rect otherClip) {
RectF boundsF = new RectF(bounds);
- matrix.mapRect(boundsF);
+ if (matrix != null) {
+ matrix.mapRect(boundsF);
+ }
clip.left = expandMinDimension(boundsF.left, clip.left, otherClip.left);
clip.top = expandMinDimension(boundsF.top, clip.top, otherClip.top);
clip.right = expandMaxDimension(boundsF.right, clip.right, otherClip.right);
@@ -256,10 +258,20 @@ public class MoveImage extends Transition {
int drawableWidth = drawable.getIntrinsicWidth();
int drawableHeight = drawable.getIntrinsicHeight();
ImageView.ScaleType scaleType = imageView.getScaleType();
- if (drawableWidth <= 0 || drawableHeight <= 0 || scaleType == ImageView.ScaleType.FIT_XY) {
- return null;
+ Matrix matrix;
+ if (drawableWidth <= 0 || drawableHeight <= 0) {
+ matrix = null;
+ } else if (scaleType == ImageView.ScaleType.FIT_XY) {
+ matrix = new Matrix();
+ float scaleX = imageView.getWidth();
+ scaleX /= drawableWidth;
+ float scaleY = imageView.getHeight();
+ scaleY /= drawableHeight;
+ matrix.setScale(scaleX, scaleY);
+ } else {
+ matrix = new Matrix(imageView.getImageMatrix());
}
- return new Matrix(imageView.getImageMatrix());
+ return matrix;
}
private Rect findClip(ImageView imageView) {