From bb6f6a52b6d176be253b1514af459a7aa4e998f8 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 25 Jul 2011 17:55:44 -0700 Subject: Fixing regression in divider visibility during spring loaded mode. (5076848) Change-Id: Ib36e78c840cd2192bdc5f30e425f82e160f63189 --- src/com/android/launcher2/Launcher.java | 9 ++++++ src/com/android/launcher2/PagedView.java | 53 +++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 795d5ccb9..5839d40ec 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2113,6 +2113,7 @@ public final class Launcher extends Activity if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); + mWorkspace.hideDockDivider(true); } } }); @@ -2138,6 +2139,7 @@ public final class Launcher extends Activity if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); + mWorkspace.hideDockDivider(true); } } } @@ -2191,6 +2193,12 @@ public final class Launcher extends Activity ((LauncherTransitionable) fromView).onLauncherTransitionStart(alphaAnim, true); } alphaAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(android.animation.Animator animation) { + if (!springLoaded) { + mWorkspace.showDockDivider(false); + } + } @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); @@ -2211,6 +2219,7 @@ public final class Launcher extends Activity if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Flash the workspace scrollbar + mWorkspace.showDockDivider(true); mWorkspace.flashScrollingIndicator(); } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 26f0e57a3..596ef50bb 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -20,6 +20,7 @@ import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -161,7 +162,8 @@ public abstract class PagedView extends ViewGroup { protected boolean mIsDataReady = false; // Scrolling indicator - private android.animation.ValueAnimator mScrollIndicatorAnimator; + private ValueAnimator mScrollIndicatorAnimator; + private android.animation.ValueAnimator mDockDividerAnimator; private ImageView mScrollIndicator; private int mScrollIndicatorPaddingLeft; private int mScrollIndicatorPaddingRight; @@ -1738,6 +1740,55 @@ public abstract class PagedView extends ViewGroup { } } + void showDockDivider(boolean immediately) { + final ViewGroup parent = (ViewGroup) getParent(); + final View divider = (ImageView) (parent.findViewById(R.id.dock_divider)); + if (divider != null) { + divider.setVisibility(View.VISIBLE); + if (mDockDividerAnimator != null) { + mDockDividerAnimator.cancel(); + } + if (immediately) { + divider.setAlpha(1f); + } else { + mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 1f); + mDockDividerAnimator.setDuration(sScrollIndicatorFadeInDuration); + mDockDividerAnimator.start(); + } + } + } + + void hideDockDivider(boolean immediately) { + final ViewGroup parent = (ViewGroup) getParent(); + final View divider = (ImageView) (parent.findViewById(R.id.dock_divider)); + if (divider != null) { + if (mDockDividerAnimator != null) { + mDockDividerAnimator.cancel(); + } + if (immediately) { + divider.setVisibility(View.GONE); + divider.setAlpha(0f); + } else { + mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 0f); + mDockDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration); + mDockDividerAnimator.addListener(new AnimatorListenerAdapter() { + private boolean cancelled = false; + @Override + public void onAnimationCancel(android.animation.Animator animation) { + cancelled = true; + } + @Override + public void onAnimationEnd(android.animation.Animator animation) { + if (!cancelled) { + divider.setVisibility(View.GONE); + } + } + }); + mDockDividerAnimator.start(); + } + } + } + /** * To be overridden by subclasses to determine whether the scroll indicator should stretch to * fill its space on the track or not. -- cgit v1.2.3