From 8edd75c8bb0729a10cb39f614183e3e9ae4288e8 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Fri, 17 Dec 2010 20:15:06 -0800 Subject: [PATCH] removing workaround for fixed animator bug Change-Id: I244b1c83f5659cf55e1f172ae33f63adbdcf2ea5 --- src/com/android/launcher2/AllAppsTabbed.java | 9 +-- src/com/android/launcher2/CellLayout.java | 4 +- .../launcher2/InterruptibleInOutAnimator.java | 4 +- src/com/android/launcher2/Launcher.java | 21 +++--- .../LauncherAnimatorListenerAdapter.java | 70 ------------------- src/com/android/launcher2/Workspace.java | 28 ++++---- 6 files changed, 32 insertions(+), 104 deletions(-) delete mode 100644 src/com/android/launcher2/LauncherAnimatorListenerAdapter.java diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java index 4feb9984cf..2cc0a6bb2e 100644 --- a/src/com/android/launcher2/AllAppsTabbed.java +++ b/src/com/android/launcher2/AllAppsTabbed.java @@ -16,9 +16,10 @@ package com.android.launcher2; -import java.util.ArrayList; +import com.android.launcher.R; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; @@ -32,7 +33,7 @@ import android.widget.TabHost; import android.widget.TabWidget; import android.widget.TextView; -import com.android.launcher.R; +import java.util.ArrayList; /** * Implements a tabbed version of AllApps2D. @@ -91,9 +92,9 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { final float alpha = mAllApps.getAlpha(); ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 0.0f). setDuration(duration); - alphaAnim.addListener(new LauncherAnimatorListenerAdapter() { + alphaAnim.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { String tag = getCurrentTabTag(); if (tag == TAG_ALL) { mAllApps.setAppFilter(AllAppsPagedView.ALL_APPS_FLAG); diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index fd0ef51d18..ef4637ee57 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -304,13 +304,13 @@ public class CellLayout extends ViewGroup implements Dimmable { AnimatorSet bouncer = new AnimatorSet(); bouncer.play(scaleUp).before(scaleDown); bouncer.play(scaleUp).with(alphaFadeOut); - bouncer.addListener(new LauncherAnimatorListenerAdapter() { + bouncer.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setHover(true); } @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { setHover(false); setHoverScale(1.0f); setHoverAlpha(1.0f); diff --git a/src/com/android/launcher2/InterruptibleInOutAnimator.java b/src/com/android/launcher2/InterruptibleInOutAnimator.java index 570b9e7734..be2fd048bf 100644 --- a/src/com/android/launcher2/InterruptibleInOutAnimator.java +++ b/src/com/android/launcher2/InterruptibleInOutAnimator.java @@ -52,9 +52,9 @@ public class InterruptibleInOutAnimator { mOriginalFromValue = fromValue; mOriginalToValue = toValue; - mAnimator.addListener(new LauncherAnimatorListenerAdapter() { + mAnimator.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { mDirection = STOPPED; } }); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index bf72add66d..40cd74b04c 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -22,6 +22,7 @@ import com.android.launcher.R; import com.android.launcher2.Workspace.ShrinkState; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; @@ -337,9 +338,9 @@ public final class Launcher extends Activity ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mCustomizePagedView, "alpha", alpha, 0.0f); alphaAnim.setDuration(duration); - alphaAnim.addListener(new LauncherAnimatorListenerAdapter() { + alphaAnim.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { String tag = mHomeCustomizationDrawer.getCurrentTabTag(); if (tag == WIDGETS_TAG) { mCustomizePagedView.setCustomizationFilter( @@ -2541,13 +2542,13 @@ public final class Launcher extends Activity if (seq != null) { Animator anim = ObjectAnimator.ofFloat(view, "alpha", show ? 1.0f : 0.0f); anim.setDuration(duration); - anim.addListener(new LauncherAnimatorListenerAdapter() { + anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { if (showing) showToolbarButton(view); } @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { if (hiding) hideToolbarButton(view); } }); @@ -2648,7 +2649,7 @@ public final class Launcher extends Activity scaleAnim.setDuration(duration); scaleAnim.setInterpolator(new Workspace.ZoomOutInterpolator()); - scaleAnim.addListener(new LauncherAnimatorListenerAdapter() { + scaleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // Prepare the position @@ -2658,7 +2659,7 @@ public final class Launcher extends Activity toView.setAlpha(1.0f); } @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { // If we don't set the final scale values here, if this animation is cancelled // it will have the wrong scale value and subsequent cameraPan animations will // not fix that @@ -2731,9 +2732,9 @@ public final class Launcher extends Activity ValueAnimator alphaAnim = ObjectAnimator.ofPropertyValuesHolder(fromView, PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.0f)); alphaAnim.setDuration(res.getInteger(R.integer.config_allAppsFadeOutTime)); - alphaAnim.addListener(new LauncherAnimatorListenerAdapter() { + alphaAnim.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); } }); @@ -2793,7 +2794,7 @@ public final class Launcher extends Activity if (animated) { if (mStateAnimation != null) mStateAnimation.cancel(); mStateAnimation = new AnimatorSet(); - mStateAnimation.addListener(new LauncherAnimatorListenerAdapter() { + mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { toView.setVisibility(View.VISIBLE); @@ -2801,7 +2802,7 @@ public final class Launcher extends Activity toView.setAlpha(1.0f); } @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); } }); diff --git a/src/com/android/launcher2/LauncherAnimatorListenerAdapter.java b/src/com/android/launcher2/LauncherAnimatorListenerAdapter.java deleted file mode 100644 index 3ab4868e3d..0000000000 --- a/src/com/android/launcher2/LauncherAnimatorListenerAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher2; - -import android.animation.Animator; - -import java.util.HashSet; - -/** - * This adapter class provides empty implementations of the methods from {@link android.animation.Animator.AnimatorListener}. - * Any custom listener that cares only about a subset of the methods of this listener can - * simply subclass this adapter class instead of implementing the interface directly. - */ -public abstract class LauncherAnimatorListenerAdapter implements Animator.AnimatorListener { - HashSet cancelled = new HashSet(); - - /** - * {@inheritDoc} - */ - @Override - public final void onAnimationCancel(Animator animation) { - onAnimationEndOrCancel(animation); - cancelled.add(animation); - } - - /** - * {@inheritDoc} - */ - @Override - public final void onAnimationEnd(Animator animation) { - if (!cancelled.contains(animation)) onAnimationEndOrCancel(animation); - cancelled.remove(animation); - } - - /** - * Like onAnimationEnd, except it's called immediately in the case on onAnimationCancel, and - * it's only called once in that case - */ - public void onAnimationEndOrCancel(Animator animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationRepeat(Animator animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationStart(Animator animation) { - } - -} diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index f70480d154..28b6ff9449 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -16,17 +16,17 @@ package com.android.launcher2; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; +import com.android.launcher.R; +import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData; import android.animation.Animator; -import android.animation.Animator.AnimatorListener; +import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; +import android.animation.Animator.AnimatorListener; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.AlertDialog; import android.app.WallpaperManager; @@ -44,7 +44,6 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Camera; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; @@ -62,12 +61,12 @@ import android.view.DragEvent; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; -import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; -import com.android.launcher.R; -import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; /** * The workspace is a wide area with a wallpaper and a finite number of pages. @@ -267,13 +266,13 @@ public class Workspace extends SmoothPagedView // In this case, we will skip drawing background protection } - mUnshrinkAnimationListener = new LauncherAnimatorListenerAdapter() { + mUnshrinkAnimationListener = new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mIsInUnshrinkAnimation = true; } @Override - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { mIsInUnshrinkAnimation = false; if (mShrinkState != ShrinkState.SPRING_LOADED) { mDrawCustomizeTrayBackground = false; @@ -1520,22 +1519,19 @@ public class Workspace extends SmoothPagedView } if (mDropAnim != null) { - // This should really be end(), but that will not be called synchronously, - // so instead we use LauncherAnimatorListenerAdapter.onAnimationEndOrCancel() - // and call cancel() here. - mDropAnim.cancel(); + mDropAnim.end(); } mDropAnim = new ValueAnimator(); mDropAnim.setInterpolator(mQuintEaseOutInterpolator); // The view is invisible during the animation; we render it manually. - mDropAnim.addListener(new LauncherAnimatorListenerAdapter() { + mDropAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationStart(Animator animation) { // Set this here so that we don't render it until the animation begins mDropView = view; } - public void onAnimationEndOrCancel(Animator animation) { + public void onAnimationEnd(Animator animation) { if (mDropView != null) { mDropView.setVisibility(View.VISIBLE); mDropView = null;