am b0b2ccf2: am 182c4d26: Merge "Delay loading All Apps pages until the first time we enter All Apps, making launcher startup faster (5000628)" into ics-mr1
* commit 'b0b2ccf2f7fe0e3095cf62a8b5543ec38b152d35': Delay loading All Apps pages until the first time we enter All Apps, making launcher startup faster (5000628)
This commit is contained in:
@@ -18,9 +18,11 @@
|
|||||||
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
|
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
|
||||||
android:background="#FF000000">
|
android:background="#FF000000">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/apps_customize_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
<!-- The layout_width of the tab bar gets overriden to align the content
|
<!-- The layout_width of the tab bar gets overriden to align the content
|
||||||
with the text in the tabs in AppsCustomizeTabHost. -->
|
with the text in the tabs in AppsCustomizeTabHost. -->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -49,9 +50,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
private AppsCustomizePagedView mAppsCustomizePane;
|
private AppsCustomizePagedView mAppsCustomizePane;
|
||||||
private boolean mSuppressContentCallback = false;
|
private boolean mSuppressContentCallback = false;
|
||||||
private FrameLayout mAnimationBuffer;
|
private FrameLayout mAnimationBuffer;
|
||||||
|
private LinearLayout mContent;
|
||||||
|
|
||||||
private boolean mInTransition;
|
private boolean mInTransition;
|
||||||
private boolean mResetAfterTransition;
|
private boolean mResetAfterTransition;
|
||||||
|
private Animator mLauncherTransition;
|
||||||
|
|
||||||
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
|
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -93,6 +96,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
mTabsContainer = tabsContainer;
|
mTabsContainer = tabsContainer;
|
||||||
mAppsCustomizePane = appsCustomizePane;
|
mAppsCustomizePane = appsCustomizePane;
|
||||||
mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer);
|
mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer);
|
||||||
|
mContent = (LinearLayout) findViewById(R.id.apps_customize_content);
|
||||||
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
|
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
|
||||||
|
|
||||||
// Configure the tabs content factory to return the same paged view (that we change the
|
// Configure the tabs content factory to return the same paged view (that we change the
|
||||||
@@ -323,21 +327,49 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LauncherTransitionable overrides */
|
private void enableAndBuildHardwareLayer() {
|
||||||
@Override
|
|
||||||
public void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) {
|
|
||||||
mInTransition = true;
|
|
||||||
// isHardwareAccelerated() checks if we're attached to a window and if that
|
// isHardwareAccelerated() checks if we're attached to a window and if that
|
||||||
// window is HW accelerated-- we were sometimes not attached to a window
|
// window is HW accelerated-- we were sometimes not attached to a window
|
||||||
// and buildLayer was throwing an IllegalStateException
|
// and buildLayer was throwing an IllegalStateException
|
||||||
if (animation != null && isHardwareAccelerated()) {
|
if (isHardwareAccelerated()) {
|
||||||
// Turn on hardware layers for performance
|
// Turn on hardware layers for performance
|
||||||
setLayerType(LAYER_TYPE_HARDWARE, null);
|
setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||||
|
|
||||||
// force building the layer at the beginning of the animation, so you don't get a
|
// force building the layer, so you don't get a blip early in an animation
|
||||||
// blip early in the animation
|
// when the layer is created layer
|
||||||
buildLayer();
|
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()) {
|
if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
|
||||||
mAppsCustomizePane.showScrollingIndicator(false);
|
mAppsCustomizePane.showScrollingIndicator(false);
|
||||||
}
|
}
|
||||||
@@ -345,6 +377,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
|||||||
mAppsCustomizePane.reset();
|
mAppsCustomizePane.reset();
|
||||||
mResetAfterTransition = false;
|
mResetAfterTransition = false;
|
||||||
}
|
}
|
||||||
|
return delayLauncherTransitionUntilLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2225,10 +2225,6 @@ public final class Launcher extends Activity
|
|||||||
alphaAnim.setStartDelay(startDelay);
|
alphaAnim.setStartDelay(startDelay);
|
||||||
alphaAnim.start();
|
alphaAnim.start();
|
||||||
|
|
||||||
if (toView instanceof LauncherTransitionable) {
|
|
||||||
((LauncherTransitionable) toView).onLauncherTransitionStart(instance, scaleAnim,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
scaleAnim.addListener(new AnimatorListenerAdapter() {
|
scaleAnim.addListener(new AnimatorListenerAdapter() {
|
||||||
boolean animationCancelled = false;
|
boolean animationCancelled = false;
|
||||||
|
|
||||||
@@ -2272,7 +2268,18 @@ public final class Launcher extends Activity
|
|||||||
// toView should appear right at the end of the workspace shrink animation
|
// toView should appear right at the end of the workspace shrink animation
|
||||||
mStateAnimation = new AnimatorSet();
|
mStateAnimation = new AnimatorSet();
|
||||||
mStateAnimation.play(scaleAnim).after(startDelay);
|
mStateAnimation.play(scaleAnim).after(startDelay);
|
||||||
mStateAnimation.start();
|
|
||||||
|
boolean delayAnim = false;
|
||||||
|
if (toView instanceof LauncherTransitionable) {
|
||||||
|
LauncherTransitionable lt = (LauncherTransitionable) toView;
|
||||||
|
delayAnim = lt.onLauncherTransitionStart(instance, mStateAnimation, false);
|
||||||
|
}
|
||||||
|
// if the anim is delayed, the LauncherTransitionable is responsible for starting it
|
||||||
|
if (!delayAnim) {
|
||||||
|
// TODO: q-- what if this anim is cancelled before being started? or started after
|
||||||
|
// being cancelled?
|
||||||
|
mStateAnimation.start();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toView.setTranslationX(0.0f);
|
toView.setTranslationX(0.0f);
|
||||||
toView.setTranslationY(0.0f);
|
toView.setTranslationY(0.0f);
|
||||||
@@ -3249,6 +3256,7 @@ public final class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface LauncherTransitionable {
|
interface LauncherTransitionable {
|
||||||
void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace);
|
// return true if the callee will take care of start the animation by itself
|
||||||
|
boolean onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace);
|
||||||
void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace);
|
void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user