Search in sources :

Example 21 with LauncherState

use of com.android.launcher3.LauncherState in project android_packages_apps_Launcher3 by crdroidandroid.

the class Launcher method restoreState.

/**
 * Restores the previous state, if it exists.
 *
 * @param savedState The previous state.
 */
private void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;
    }
    int stateOrdinal = savedState.getInt(RUNTIME_STATE, NORMAL.ordinal);
    LauncherState[] stateValues = LauncherState.values();
    LauncherState state = stateValues[stateOrdinal];
    NonConfigInstance lastInstance = (NonConfigInstance) getLastNonConfigurationInstance();
    boolean forceRestore = lastInstance != null && (lastInstance.config.diff(mOldConfig) & CONFIG_UI_MODE) != 0;
    if (forceRestore || !state.shouldDisableRestore()) {
        mStateManager.goToState(state, false);
    }
    PendingRequestArgs requestArgs = savedState.getParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS);
    if (requestArgs != null) {
        setWaitingForResult(requestArgs);
    }
    mPendingActivityRequestCode = savedState.getInt(RUNTIME_STATE_PENDING_REQUEST_CODE);
    mPendingActivityResult = savedState.getParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT);
    SparseArray<Parcelable> widgetsState = savedState.getSparseParcelableArray(RUNTIME_STATE_WIDGET_PANEL);
    if (widgetsState != null) {
        WidgetsFullSheet.show(this, false).restoreHierarchyState(widgetsState);
    }
}
Also used : Parcelable(android.os.Parcelable) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs)

Example 22 with LauncherState

use of com.android.launcher3.LauncherState in project android_packages_apps_Launcher3 by crdroidandroid.

the class AllAppsTransitionController method setState.

/**
 * Sets the vertical transition progress to {@param state} and updates all the dependent UI
 * accordingly.
 */
@Override
public void setState(LauncherState state) {
    setProgress(state.getVerticalProgress(mLauncher));
    setAlphas(state, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER);
    onProgressAnimationEnd();
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

Example 23 with LauncherState

use of com.android.launcher3.LauncherState in project android_packages_apps_Launcher3 by crdroidandroid.

the class OverviewToHomeAnim method animateWithVelocity.

/**
 * Starts the animation. If velocity < 0 (i.e. upwards), also plays a
 * {@link WorkspaceRevealAnim}.
 */
public void animateWithVelocity(float velocity) {
    StateManager<LauncherState> stateManager = mLauncher.getStateManager();
    LauncherState startState = stateManager.getState();
    if (startState != OVERVIEW) {
        Log.e(TAG, "animateFromOverviewToHome: unexpected start state " + startState);
    }
    AnimatorSet anim = new AnimatorSet();
    boolean playWorkspaceRevealAnim = velocity < 0;
    if (playWorkspaceRevealAnim) {
        WorkspaceRevealAnim workspaceRevealAnim = new WorkspaceRevealAnim(mLauncher, false);
        workspaceRevealAnim.addAnimatorListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                mIsHomeStaggeredAnimFinished = true;
                maybeOverviewToHomeAnimComplete();
            }
        });
        anim.play(workspaceRevealAnim.getAnimators());
    } else {
        mIsHomeStaggeredAnimFinished = true;
    }
    StateAnimationConfig config = new StateAnimationConfig();
    if (playWorkspaceRevealAnim) {
        // WorkspaceRevealAnim handles the depth, so don't interfere.
        config.animFlags |= StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
    }
    config.duration = startState.getTransitionDuration(mLauncher);
    AnimatorSet stateAnim = stateManager.createAtomicAnimation(startState, NORMAL, config);
    stateAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            mIsOverviewHidden = true;
            maybeOverviewToHomeAnimComplete();
        }
    });
    anim.play(stateAnim);
    stateManager.setCurrentAnimation(anim, NORMAL);
    anim.start();
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorSet(android.animation.AnimatorSet) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 24 with LauncherState

use of com.android.launcher3.LauncherState in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherRecentsView method onTaskLaunchAnimationEnd.

@Override
protected void onTaskLaunchAnimationEnd(boolean success) {
    if (success) {
        mActivity.getStateManager().moveToRestState();
    } else {
        LauncherState state = mActivity.getStateManager().getState();
        mActivity.getAllAppsController().setState(state);
    }
    super.onTaskLaunchAnimationEnd(success);
}
Also used : LauncherState(com.android.launcher3.LauncherState)

Aggregations

LauncherState (com.android.launcher3.LauncherState)14 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)8 Animator (android.animation.Animator)4 PendingAnimation (com.android.launcher3.anim.PendingAnimation)4 ValueAnimator (android.animation.ValueAnimator)3 RecentsView (com.android.quickstep.views.RecentsView)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorSet (android.animation.AnimatorSet)2 Interpolator (android.view.animation.Interpolator)2 PendingRequestArgs (com.android.launcher3.util.PendingRequestArgs)2 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 Parcelable (android.os.Parcelable)1 FloatProperty (android.util.FloatProperty)1 View (android.view.View)1 VISIBLE (android.view.View.VISIBLE)1 ImageView (android.widget.ImageView)1 Nullable (androidx.annotation.Nullable)1 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)1 CellLayout (com.android.launcher3.CellLayout)1 DeviceProfile (com.android.launcher3.DeviceProfile)1