summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-05-31 13:23:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-31 13:23:05 -0700
commit57830506bf4fbd7e9093510223ae9b43e4047f7f (patch)
treefb96f5aee096bd48946299c0c478b2463a674381
parent6f8e526e2818e4ceb39cede79abcf2d48cfc4c8f (diff)
parentdcc4665292c70ba18a8a1297482b8c5c48ca992d (diff)
downloadandroid_packages_apps_Trebuchet-57830506bf4fbd7e9093510223ae9b43e4047f7f.zip
android_packages_apps_Trebuchet-57830506bf4fbd7e9093510223ae9b43e4047f7f.tar.gz
android_packages_apps_Trebuchet-57830506bf4fbd7e9093510223ae9b43e4047f7f.tar.bz2
am dcc46652: Merge "Simplifying search bar animations. (Bug 6529767)" into jb-dev
* commit 'dcc4665292c70ba18a8a1297482b8c5c48ca992d': Simplifying search bar animations. (Bug 6529767)
-rw-r--r--src/com/android/launcher2/SearchDropTargetBar.java92
1 files changed, 34 insertions, 58 deletions
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index a01fd3a..77681a8 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -18,7 +18,6 @@ package com.android.launcher2;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Rect;
@@ -26,7 +25,6 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
-import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import com.android.launcher.R;
@@ -40,10 +38,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
private static final int sTransitionInDuration = 200;
private static final int sTransitionOutDuration = 175;
- private ObjectAnimator mDropTargetBarFadeInAnim;
- private ObjectAnimator mDropTargetBarFadeOutAnim;
- private ObjectAnimator mQSBSearchBarFadeInAnim;
- private ObjectAnimator mQSBSearchBarFadeOutAnim;
+ private ObjectAnimator mDropTargetBarAnim;
+ private ObjectAnimator mQSBSearchBarAnim;
+ private static final AccelerateInterpolator sAccelerateInterpolator =
+ new AccelerateInterpolator();
private boolean mIsSearchBarHidden;
private View mQSBSearchBar;
@@ -75,28 +73,19 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mDeleteDropTarget.setLauncher(launcher);
}
- // This sets up the view for the animation
private void prepareStartAnimation(View v) {
- // Enable the hw layers (which will be disabled in the onAnimationEnd callback below
+ // Enable the hw layers before the animation starts (will be disabled in the onAnimationEnd
+ // callback below)
v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
v.buildLayer();
}
- private void prepareAnimation(ObjectAnimator in, ObjectAnimator out, final View v) {
- in.setInterpolator(new AccelerateInterpolator());
- in.setDuration(sTransitionInDuration);
- in.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationStart(Animator animation) {
- v.setVisibility(View.VISIBLE);
- }
- });
- out.setInterpolator(new AccelerateInterpolator());
- out.setDuration(sTransitionOutDuration);
- out.addListener(new AnimatorListenerAdapter() {
+ private void setupAnimation(ObjectAnimator anim, final View v) {
+ anim.setInterpolator(sAccelerateInterpolator);
+ anim.setDuration(sTransitionInDuration);
+ anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- v.setVisibility(View.INVISIBLE);
v.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
@@ -122,64 +111,55 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Create the various fade animations
if (mEnableDropDownDropTargets) {
mDropTargetBar.setTranslationY(-mBarHeight);
- mDropTargetBarFadeInAnim = ObjectAnimator.ofFloat(mDropTargetBar, "translationY", 0f);
- mDropTargetBarFadeOutAnim = ObjectAnimator.ofFloat(mDropTargetBar, "translationY",
- -mBarHeight);
- mQSBSearchBarFadeInAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "translationY", 0);
- mQSBSearchBarFadeOutAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "translationY",
+ mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, "translationY",
+ -mBarHeight, 0f);
+ mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "translationY", 0,
-mBarHeight);
} else {
mDropTargetBar.setAlpha(0f);
- mDropTargetBarFadeInAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 1f);
- mDropTargetBarFadeOutAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f);
- mQSBSearchBarFadeInAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 1f);
- mQSBSearchBarFadeOutAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 0f);
+ mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f, 1f);
+ mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
}
- prepareAnimation(mDropTargetBarFadeInAnim, mDropTargetBarFadeOutAnim, mDropTargetBar);
- prepareAnimation(mQSBSearchBarFadeInAnim, mQSBSearchBarFadeOutAnim, mQSBSearchBar);
+ setupAnimation(mDropTargetBarAnim, mDropTargetBar);
+ setupAnimation(mQSBSearchBarAnim, mQSBSearchBar);
}
public void finishAnimations() {
- mDropTargetBarFadeInAnim.end();
- mDropTargetBarFadeOutAnim.end();
- mQSBSearchBarFadeInAnim.end();
- mQSBSearchBarFadeOutAnim.end();
- }
-
- private void cancelSearchBarAnimations() {
- mQSBSearchBarFadeInAnim.cancel();
- mQSBSearchBarFadeOutAnim.cancel();
+ prepareStartAnimation(mDropTargetBar);
+ mDropTargetBarAnim.reverse();
+ prepareStartAnimation(mQSBSearchBar);
+ mQSBSearchBarAnim.reverse();
}
/*
* Shows and hides the search bar.
*/
public void showSearchBar(boolean animated) {
- cancelSearchBarAnimations();
+ if (!mIsSearchBarHidden) return;
if (animated) {
prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarFadeInAnim.start();
+ mQSBSearchBarAnim.reverse();
} else {
- mQSBSearchBar.setVisibility(View.VISIBLE);
+ mQSBSearchBarAnim.cancel();
if (mEnableDropDownDropTargets) {
mQSBSearchBar.setTranslationY(0);
} else {
- mQSBSearchBar.setAlpha(1f);
+ mDropTargetBar.setAlpha(1f);
}
}
mIsSearchBarHidden = false;
}
public void hideSearchBar(boolean animated) {
- cancelSearchBarAnimations();
+ if (mIsSearchBarHidden) return;
if (animated) {
prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarFadeOutAnim.start();
+ mQSBSearchBarAnim.start();
} else {
- mQSBSearchBar.setVisibility(View.INVISIBLE);
+ mQSBSearchBarAnim.cancel();
if (mEnableDropDownDropTargets) {
- mQSBSearchBar.setTranslationY(0);
+ mQSBSearchBar.setTranslationY(-mBarHeight);
} else {
- mQSBSearchBar.setAlpha(0f);
+ mDropTargetBar.setAlpha(0f);
}
}
mIsSearchBarHidden = true;
@@ -202,12 +182,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
public void onDragStart(DragSource source, Object info, int dragAction) {
// Animate out the QSB search bar, and animate in the drop target bar
prepareStartAnimation(mDropTargetBar);
- mDropTargetBarFadeOutAnim.cancel();
- mDropTargetBarFadeInAnim.start();
+ mDropTargetBarAnim.start();
if (!mIsSearchBarHidden) {
prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarFadeInAnim.cancel();
- mQSBSearchBarFadeOutAnim.start();
+ mQSBSearchBarAnim.start();
}
}
@@ -220,12 +198,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
if (!mDeferOnDragEnd) {
// Restore the QSB search bar, and animate out the drop target bar
prepareStartAnimation(mDropTargetBar);
- mDropTargetBarFadeInAnim.cancel();
- mDropTargetBarFadeOutAnim.start();
+ mDropTargetBarAnim.reverse();
if (!mIsSearchBarHidden) {
prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarFadeOutAnim.cancel();
- mQSBSearchBarFadeInAnim.start();
+ mQSBSearchBarAnim.reverse();
}
} else {
mDeferOnDragEnd = false;