diff options
author | Michael Jurka <mikejurka@google.com> | 2011-07-25 17:57:40 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-07-26 15:49:50 -0700 |
commit | b9e14974ae5c03bd996bc102ed23a24126449990 (patch) | |
tree | 85306d50b2094e73679f8490f190999271ea986a /src | |
parent | bf361decc703800d7db41ac87d1e3c87011b2c32 (diff) | |
download | android_packages_apps_Trebuchet-b9e14974ae5c03bd996bc102ed23a24126449990.tar.gz android_packages_apps_Trebuchet-b9e14974ae5c03bd996bc102ed23a24126449990.tar.bz2 android_packages_apps_Trebuchet-b9e14974ae5c03bd996bc102ed23a24126449990.zip |
Solving transient wallpaper flash when rotating All Apps
- also cleaning up some code
Change-Id: Ic9399e604aac3115d92186a70799bf80ecaf31c6
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 77 |
2 files changed, 49 insertions, 38 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 5839d40ec..efdc6b01e 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -43,16 +43,11 @@ import android.content.IntentFilter; import android.content.Intent.ShortcutIconResource; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; -import android.content.res.TypedArray; import android.database.ContentObserver; -import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; @@ -79,7 +74,6 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; -import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.accessibility.AccessibilityEvent; import android.view.animation.DecelerateInterpolator; @@ -87,14 +81,11 @@ import android.view.inputmethod.InputMethodManager; import android.widget.Advanceable; import android.widget.EditText; import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; import com.android.common.Search; import com.android.launcher.R; -import com.android.launcher2.Workspace.State; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -102,7 +93,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; /** * Default launcher application. diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index a198c6d35..23b8c2d99 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -991,38 +991,59 @@ public class Workspace extends SmoothPagedView mDrawBackground = true; } - private void showBackgroundGradientForAllApps() { - showBackgroundGradient(); + private void showBackgroundGradientForAllApps(boolean animated) { + showBackgroundGradient(animated); } - private void showBackgroundGradient() { + private void showBackgroundGradient(boolean animated) { if (mBackground == null) return; - if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel(); - if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel(); - mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 1f); - mBackgroundFadeInAnimation.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); - } - }); - mBackgroundFadeInAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); - mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION); - mBackgroundFadeInAnimation.start(); + if (mBackgroundFadeOutAnimation != null) { + mBackgroundFadeOutAnimation.cancel(); + mBackgroundFadeOutAnimation = null; + } + if (mBackgroundFadeInAnimation != null) { + mBackgroundFadeInAnimation.cancel(); + mBackgroundFadeInAnimation = null; + } + final float finalAlpha = 1f; + if (animated) { + mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); + mBackgroundFadeInAnimation.addUpdateListener(new AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); + } + }); + mBackgroundFadeInAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION); + mBackgroundFadeInAnimation.start(); + } else { + setBackgroundAlpha(finalAlpha); + } } - private void hideBackgroundGradient(float finalAlpha) { + private void hideBackgroundGradient(float finalAlpha, boolean animated) { if (mBackground == null) return; - if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel(); - if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel(); - mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); - mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { - public void onAnimationUpdate(ValueAnimator animation) { - setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); - } - }); - mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); - mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); - mBackgroundFadeOutAnimation.start(); + if (mBackgroundFadeInAnimation != null) { + mBackgroundFadeInAnimation.cancel(); + mBackgroundFadeInAnimation = null; + } + if (mBackgroundFadeOutAnimation != null) { + mBackgroundFadeOutAnimation.cancel(); + mBackgroundFadeOutAnimation = null; + } + if (animated) { + mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); + mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); + } + }); + mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); + mBackgroundFadeOutAnimation.start(); + } else { + setBackgroundAlpha(finalAlpha); + } } public void setBackgroundAlpha(float alpha) { @@ -1523,7 +1544,7 @@ public class Workspace extends SmoothPagedView } setChildrenDrawnWithCacheEnabled(true); - showBackgroundGradientForAllApps(); + showBackgroundGradientForAllApps(animated); } @Override @@ -1876,7 +1897,7 @@ public class Workspace extends SmoothPagedView } hideBackgroundGradient(springLoaded ? getResources().getInteger( - R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f); + R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f, animated); } /** |