summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/AppsCustomizeTabHost.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-11-03 13:50:45 -0700
committerMichael Jurka <mikejurka@google.com>2011-11-13 17:08:23 -0800
commit1899a36ab3aab7671420511f47eb8b273b9b1078 (patch)
tree9220a93a8a4b8cffaa4aca7dd72d29939afa27e1 /src/com/android/launcher2/AppsCustomizeTabHost.java
parentc46fbf04eaa8311d1775e70e65f3dd292e3ce715 (diff)
downloadandroid_packages_apps_Trebuchet-1899a36ab3aab7671420511f47eb8b273b9b1078.tar.gz
android_packages_apps_Trebuchet-1899a36ab3aab7671420511f47eb8b273b9b1078.tar.bz2
android_packages_apps_Trebuchet-1899a36ab3aab7671420511f47eb8b273b9b1078.zip
Delay loading All Apps pages until the first time we enter All Apps, making launcher startup faster (5000628)
Change-Id: I2a2218975141d7659184de83e505c7ab6e613232
Diffstat (limited to 'src/com/android/launcher2/AppsCustomizeTabHost.java')
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 41f8d7e1a..e79d41f5f 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -28,6 +28,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
@@ -49,9 +50,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private AppsCustomizePagedView mAppsCustomizePane;
private boolean mSuppressContentCallback = false;
private FrameLayout mAnimationBuffer;
+ private LinearLayout mContent;
private boolean mInTransition;
private boolean mResetAfterTransition;
+ private Animator mLauncherTransition;
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -93,6 +96,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mTabsContainer = tabsContainer;
mAppsCustomizePane = appsCustomizePane;
mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer);
+ mContent = (LinearLayout) findViewById(R.id.apps_customize_content);
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
// Configure the tabs content factory to return the same paged view (that we change the
@@ -313,21 +317,49 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
}
- /* LauncherTransitionable overrides */
- @Override
- public void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
- mInTransition = true;
+ private void enableAndBuildHardwareLayer() {
// isHardwareAccelerated() checks if we're attached to a window and if that
// window is HW accelerated-- we were sometimes not attached to a window
// and buildLayer was throwing an IllegalStateException
- if (animation != null && isHardwareAccelerated()) {
+ if (isHardwareAccelerated()) {
// Turn on hardware layers for performance
setLayerType(LAYER_TYPE_HARDWARE, null);
- // force building the layer at the beginning of the animation, so you don't get a
- // blip early in the animation
+ // force building the layer, so you don't get a blip early in an animation
+ // when the layer is created layer
buildLayer();
}
+ }
+
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ if (mLauncherTransition != null) {
+ enableAndBuildHardwareLayer();
+ mLauncherTransition.start();
+ mLauncherTransition = null;
+ }
+ }
+
+ /* LauncherTransitionable overrides */
+ @Override
+ public boolean onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
+ mInTransition = true;
+ boolean delayLauncherTransitionUntilLayout = false;
+ mLauncherTransition = null;
+
+ // if the content wasn't visible before, delay the launcher animation until after a cal
+ // to layout -- this prevents a blip
+ if (animation != null) {
+ if (mContent.getVisibility() == GONE) {
+ mLauncherTransition = animation;
+ delayLauncherTransitionUntilLayout = true;
+ }
+ mContent.setVisibility(VISIBLE);
+ if (!delayLauncherTransitionUntilLayout) {
+ enableAndBuildHardwareLayer();
+ }
+ }
+
if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
mAppsCustomizePane.showScrollingIndicator(false);
}
@@ -335,6 +367,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mAppsCustomizePane.reset();
mResetAfterTransition = false;
}
+ return delayLauncherTransitionUntilLayout;
}
@Override