summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-08-15 16:36:44 -0700
committerAndrew Lee <anwlee@google.com>2014-08-18 10:20:46 -0700
commit5ead1b9b7742203fc0f08bee39fee79939cbfed3 (patch)
tree4d97fced49244441db7656607eacb519b3d8be6c /src
parent43af52a346443ac8d4c7057215888e6b36d9175b (diff)
downloadandroid_packages_apps_PhoneCommon-5ead1b9b7742203fc0f08bee39fee79939cbfed3.tar.gz
android_packages_apps_PhoneCommon-5ead1b9b7742203fc0f08bee39fee79939cbfed3.tar.bz2
android_packages_apps_PhoneCommon-5ead1b9b7742203fc0f08bee39fee79939cbfed3.zip
Add a changeDimensions method which animates a width/height change.
Bug: 16399233 Change-Id: I1b5f9b2e487fcb95c380b9eb94f7cbbbf2d98571
Diffstat (limited to 'src')
-rw-r--r--src/com/android/phone/common/animation/AnimUtils.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/phone/common/animation/AnimUtils.java b/src/com/android/phone/common/animation/AnimUtils.java
index 35ac107..3a5f679 100644
--- a/src/com/android/phone/common/animation/AnimUtils.java
+++ b/src/com/android/phone/common/animation/AnimUtils.java
@@ -18,11 +18,14 @@ package com.android.phone.common.animation;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
+import java.lang.Float;
+
public class AnimUtils {
public static final int DEFAULT_DURATION = -1;
public static final Interpolator EASE_IN = new PathInterpolator(0.0f, 0.0f, 0.2f, 1.0f);
@@ -105,4 +108,31 @@ public class AnimUtils {
}
animator.start();
}
+
+ /**
+ * Animates a view to the new specified dimensions.
+ * @param view The view to change the dimensions of.
+ * @param newWidth The new width of the view.
+ * @param newHeight The new height of the view.
+ */
+ public static void changeDimensions(final View view, final int newWidth, final int newHeight) {
+ ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
+
+ final int oldWidth = view.getWidth();
+ final int oldHeight = view.getHeight();
+ final int deltaWidth = newWidth - oldWidth;
+ final int deltaHeight = newHeight - oldHeight;
+
+ animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ Float value = (Float) animator.getAnimatedValue();
+
+ view.getLayoutParams().width = (int) (value * deltaWidth + oldWidth);
+ view.getLayoutParams().height = (int) (value * deltaHeight + oldHeight);
+ view.requestLayout();
+ }
+ });
+ animator.start();
+ }
}