Fixing regression in divider visibility during spring loaded mode. (5076848)
Change-Id: Ib36e78c840cd2192bdc5f30e425f82e160f63189
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 795d5cc..5839d40 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2113,6 +2113,7 @@
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
+ mWorkspace.hideDockDivider(true);
}
}
});
@@ -2138,6 +2139,7 @@
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
+ mWorkspace.hideDockDivider(true);
}
}
}
@@ -2192,6 +2194,12 @@
}
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);
if (fromView instanceof LauncherTransitionable) {
@@ -2211,6 +2219,7 @@
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 26f0e57..596ef50 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -20,6 +20,7 @@
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 @@
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 @@
}
}
+ 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.