From e0f5a61a1f105216b0067124bacac69194c0ef70 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Mon, 7 Feb 2011 16:45:41 -0800 Subject: Speeding up the first time All Apps and Configure is launched Change-Id: Ic9503f62ee4458b7797add4ac9a2cb4b0a186a30 --- src/com/android/launcher2/Launcher.java | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/com/android/launcher2/Launcher.java') diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index dc2e5de02..5779c6ad1 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -88,6 +88,7 @@ import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.accessibility.AccessibilityEvent; import android.view.animation.DecelerateInterpolator; @@ -1053,6 +1054,31 @@ public final class Launcher extends Activity mAllAppsButton = findViewById(R.id.all_apps_button); mDivider = findViewById(R.id.divider); mConfigureButton = findViewById(R.id.configure_button); + + // We had previously set these click handlers in XML, but the first time we launched + // Configure or All Apps we had an extra 50ms of delay while the java reflection methods + // found the right handler. Setting the handlers directly here eliminates that cost. + if (mConfigureButton != null) { + mConfigureButton.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + onClickConfigureButton(v); + } + }); + } + if (mDivider != null) { + mDivider.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + onClickAllAppsButton(v); + } + }); + } + if (mAllAppsButton != null) { + mAllAppsButton.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + onClickAllAppsButton(v); + } + }); + } } @SuppressWarnings({"UnusedDeclaration"}) @@ -2577,8 +2603,13 @@ public final class Launcher extends Activity getResources().getInteger(R.integer.config_toolbarButtonFadeOutTime); if (seq != null) { - Animator anim = ObjectAnimator.ofFloat(view, "alpha", show ? 1.0f : 0.0f); + ValueAnimator anim = ValueAnimator.ofFloat(view.getAlpha(), show ? 1.0f : 0.0f); anim.setDuration(duration); + anim.addUpdateListener(new AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + view.setAlpha((Float) animation.getAnimatedValue()); + } + }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { -- cgit v1.2.3