From 228a0faca6fd77f5cdd28a32ff20a311ec1bbffa Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 26 Jan 2011 22:14:13 -0800 Subject: [PATCH] Using newer object animators for click feedback animation. (3384873) Change-Id: I50d3a506f2fec3fb868616e3d969d2911fae6706 --- res/anim/paged_view_click_feedback.xml | 13 +++++++------ src/com/android/launcher2/PagedView.java | 23 ++++++++++------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/res/anim/paged_view_click_feedback.xml b/res/anim/paged_view_click_feedback.xml index d1e6e2360f..eb7ecef15c 100644 --- a/res/anim/paged_view_click_feedback.xml +++ b/res/anim/paged_view_click_feedback.xml @@ -14,10 +14,11 @@ limitations under the License. --> - + android:repeatMode="reverse"/> diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index d99921f9f9..c9044b4d06 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -18,6 +18,10 @@ package com.android.launcher2; import java.util.ArrayList; +import android.animation.Animator; +import android.animation.AnimatorInflater; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -32,9 +36,6 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewParent; -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; -import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.Checkable; import android.widget.Scroller; @@ -809,19 +810,15 @@ public abstract class PagedView extends ViewGroup { protected void animateClickFeedback(View v, final Runnable r) { // animate the view slightly to show click feedback running some logic after it is "pressed" - Animation anim = AnimationUtils.loadAnimation(getContext(), - R.anim.paged_view_click_feedback); - anim.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - @Override - public void onAnimationRepeat(Animation animation) { + ObjectAnimator anim = (ObjectAnimator) AnimatorInflater. + loadAnimator(mContext, R.anim.paged_view_click_feedback); + anim.setTarget(v); + anim.addListener(new AnimatorListenerAdapter() { + public void onAnimationRepeat(Animator animation) { r.run(); } - @Override - public void onAnimationEnd(Animation animation) {} }); - v.startAnimation(anim); + anim.start(); } /*