From 608b87d9e57b71a86374a439bf5c3febd1e142f2 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 15 Apr 2014 09:01:32 -0700 Subject: Add Transform and ClipBounds Transitions. Made MoveImage use an overlay view. Drawables cover all Views in the overlay and there may be a desire to order the overlays. Change-Id: Ic7b81f0d26d8cce3f475c2eebbce01538bc55d46 --- core/java/android/transition/MoveImage.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'core/java/android/transition/MoveImage.java') diff --git a/core/java/android/transition/MoveImage.java b/core/java/android/transition/MoveImage.java index d68e971..e4c3939 100644 --- a/core/java/android/transition/MoveImage.java +++ b/core/java/android/transition/MoveImage.java @@ -170,13 +170,20 @@ public class MoveImage extends Transition { drawable = drawable.getConstantState().newDrawable(); final MatrixClippedDrawable matrixClippedDrawable = new MatrixClippedDrawable(drawable); + final ImageView overlayImage = new ImageView(imageView.getContext()); + final ViewGroupOverlay overlay = sceneRoot.getOverlay(); + overlay.add(overlayImage); + overlayImage.setLeft(0); + overlayImage.setTop(0); + overlayImage.setRight(sceneRoot.getWidth()); + overlayImage.setBottom(sceneRoot.getBottom()); + overlayImage.setScaleType(ImageView.ScaleType.MATRIX); + overlayImage.setImageDrawable(matrixClippedDrawable); matrixClippedDrawable.setMatrix(startMatrix); matrixClippedDrawable.setBounds(startBounds); matrixClippedDrawable.setClipRect(startClip); imageView.setVisibility(View.INVISIBLE); - final ViewGroupOverlay overlay = sceneRoot.getOverlay(); - overlay.add(matrixClippedDrawable); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(matrixClippedDrawable, changes.toArray(new PropertyValuesHolder[changes.size()])); @@ -184,19 +191,24 @@ public class MoveImage extends Transition { @Override public void onAnimationEnd(Animator animation) { imageView.setVisibility(View.VISIBLE); - overlay.remove(matrixClippedDrawable); + overlay.remove(overlayImage); } @Override public void onAnimationPause(Animator animation) { imageView.setVisibility(View.VISIBLE); - overlay.remove(matrixClippedDrawable); + overlayImage.setVisibility(View.INVISIBLE); } @Override public void onAnimationResume(Animator animation) { imageView.setVisibility(View.INVISIBLE); - overlay.add(matrixClippedDrawable); + overlayImage.setVisibility(View.VISIBLE); + } + + @Override + public void onAnimationCancel(Animator animation) { + onAnimationEnd(animation); } }; -- cgit v1.1