summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-02-07 16:45:41 -0800
committerMichael Jurka <mikejurka@google.com>2011-02-09 13:47:34 -0800
commite0f5a61a1f105216b0067124bacac69194c0ef70 (patch)
treedc44ddfd1cddffe3c35906427fee6910eec55e02
parent838a4ca645389a1c1fc49e2f1ea0726331b8a538 (diff)
downloadandroid_packages_apps_Trebuchet-e0f5a61a1f105216b0067124bacac69194c0ef70.tar.gz
android_packages_apps_Trebuchet-e0f5a61a1f105216b0067124bacac69194c0ef70.tar.bz2
android_packages_apps_Trebuchet-e0f5a61a1f105216b0067124bacac69194c0ef70.zip
Speeding up the first time All Apps and Configure is launched
Change-Id: Ic9503f62ee4458b7797add4ac9a2cb4b0a186a30
-rw-r--r--res/layout-xlarge-land/launcher.xml3
-rw-r--r--res/layout-xlarge-port/launcher.xml3
-rw-r--r--src/com/android/launcher2/Launcher.java33
-rw-r--r--src/com/android/launcher2/Workspace.java18
4 files changed, 46 insertions, 11 deletions
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 957327ebf..590787fc7 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -113,7 +113,6 @@
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
android:background="@drawable/button_bg"
- android:onClick="onClickConfigureButton"
android:focusable="true"
android:clickable="true" />
<ImageView
@@ -125,7 +124,6 @@
android:paddingTop="@dimen/toolbar_button_vertical_padding"
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- android:onClick="onClickAllAppsButton"
android:focusable="false"
android:clickable="true" />
<TextView
@@ -151,7 +149,6 @@
android:shadowDy="0.0"
android:shadowRadius="2.5"
- android:onClick="onClickAllAppsButton"
android:focusable="true"
android:clickable="true" />
<ImageView
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index a8087f450..4c83fdabf 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -113,7 +113,6 @@
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
android:background="@drawable/button_bg"
- android:onClick="onClickConfigureButton"
android:focusable="true"
android:clickable="true" />
<ImageView
@@ -125,7 +124,6 @@
android:paddingTop="@dimen/toolbar_button_vertical_padding"
android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- android:onClick="onClickAllAppsButton"
android:focusable="false"
android:clickable="true" />
<TextView
@@ -151,7 +149,6 @@
android:shadowDy="0.0"
android:shadowRadius="2.5"
- android:onClick="onClickAllAppsButton"
android:focusable="true"
android:clickable="true" />
<ImageView
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) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 0daed37f8..2ea49313e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -108,8 +108,8 @@ public class Workspace extends SmoothPagedView
private float mChildrenOutlineAlpha = 0;
// These properties refer to the background protection gradient used for AllApps and Customize
- private ObjectAnimator mBackgroundFadeInAnimation;
- private ObjectAnimator mBackgroundFadeOutAnimation;
+ private ValueAnimator mBackgroundFadeInAnimation;
+ private ValueAnimator mBackgroundFadeOutAnimation;
private Drawable mBackground;
private Drawable mCustomizeTrayBackground;
private boolean mDrawCustomizeTrayBackground;
@@ -938,7 +938,12 @@ public class Workspace extends SmoothPagedView
if (mBackground == null) return;
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
- mBackgroundFadeInAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 1.0f);
+ 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();
@@ -948,7 +953,12 @@ public class Workspace extends SmoothPagedView
if (mBackground == null) return;
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
- mBackgroundFadeOutAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 0.0f);
+ mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 0f);
+ 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();