Search in sources :

Example 71 with AnimatorSet

use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.

the class LauncherTransitionable method runNewAppsAnimation.

/**
	 * Runs a new animation that scales up icons that were added while Launcher
	 * was in the background.
	 * 
	 * @param immediate
	 *            whether to run the animation or show the results immediately
	 */
private void runNewAppsAnimation(boolean immediate) {
    AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
    Collection<Animator> bounceAnims = new ArrayList<Animator>();
    // Order these new views spatially so that they animate in order
    Collections.sort(mNewShortcutAnimateViews, new Comparator<View>() {

        @Override
        public int compare(View a, View b) {
            CellLayout.LayoutParams alp = (CellLayout.LayoutParams) a.getLayoutParams();
            CellLayout.LayoutParams blp = (CellLayout.LayoutParams) b.getLayoutParams();
            int cellCountX = LauncherModel.getCellCountX();
            return (alp.cellY * cellCountX + alp.cellX) - (blp.cellY * cellCountX + blp.cellX);
        }
    });
    // requested)
    if (immediate) {
        for (View v : mNewShortcutAnimateViews) {
            v.setAlpha(1f);
            v.setScaleX(1f);
            v.setScaleY(1f);
        }
    } else {
        for (int i = 0; i < mNewShortcutAnimateViews.size(); ++i) {
            View v = mNewShortcutAnimateViews.get(i);
            ValueAnimator bounceAnim = LauncherAnimUtils.ofPropertyValuesHolder(v, PropertyValuesHolder.ofFloat("alpha", 1f), PropertyValuesHolder.ofFloat("scaleX", 1f), PropertyValuesHolder.ofFloat("scaleY", 1f));
            bounceAnim.setDuration(InstallShortcutReceiver.NEW_SHORTCUT_BOUNCE_DURATION);
            bounceAnim.setStartDelay(i * InstallShortcutReceiver.NEW_SHORTCUT_STAGGER_DELAY);
            bounceAnim.setInterpolator(new SmoothPagedView.OvershootInterpolator());
            bounceAnims.add(bounceAnim);
        }
        anim.playTogether(bounceAnims);
        anim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (mWorkspace != null) {
                    mWorkspace.postDelayed(mBuildLayersRunnable, 500);
                }
            }
        });
        anim.start();
    }
    // Clean up
    mNewShortcutAnimatePage = -1;
    mNewShortcutAnimateViews.clear();
    new Thread("clearNewAppsThread") {

        public void run() {
            mSharedPrefs.edit().putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1).putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, null).commit();
        }
    }.start();
}
Also used : ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 72 with AnimatorSet

use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.

the class LauncherTransitionable method showAppsCustomizeHelper.

/**
	 * Things to test when changing the following seven functions. - Home from
	 * workspace - from center screen - from other screens - Home from all apps
	 * - from center screen - from other screens - Back from all apps - from
	 * center screen - from other screens - Launch app from workspace and quit -
	 * with back - with home - Launch app from all apps and quit - with back -
	 * with home - Go to a screen that's not the default, then all apps, and
	 * launch and app, and go back - with back -with home - On workspace, long
	 * press power and go back - with back - with home - On all apps, long press
	 * power and go back - with back - with home - On workspace, power off - On
	 * all apps, power off - Launch an app and turn off the screen while in that
	 * app - Go back with home key - Go back with back key TODO: make this not
	 * go to workspace - From all apps - From workspace - Enter and exit car
	 * mode (becuase it causes an extra configuration changed) - From all apps -
	 * From the center workspace - From another workspace
	 */
/**
	 * Zoom the camera out from the workspace to reveal 'toView'. Assumes that
	 * the view to show is anchored at either the very top or very bottom of the
	 * screen.
	 */
private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded) {
    if (mStateAnimation != null) {
        mStateAnimation.cancel();
        mStateAnimation = null;
    }
    final Resources res = getResources();
    final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime);
    final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime);
    final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
    final View fromView = mWorkspace;
    final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;
    final int startDelay = res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger);
    setPivotsForZoom(toView, scale);
    // Shrink workspaces away if going to AppsCustomize from workspace
    Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated);
    if (animated) {
        toView.setScaleX(scale);
        toView.setScaleY(scale);
        final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView);
        scaleAnim.scaleX(1f).scaleY(1f).setDuration(duration).setInterpolator(new Workspace.ZoomOutInterpolator());
        toView.setVisibility(View.VISIBLE);
        toView.setAlpha(0f);
        final ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(toView, "alpha", 0f, 1f).setDuration(fadeDuration);
        alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f));
        alphaAnim.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                if (animation == null) {
                    throw new RuntimeException("animation is null");
                }
                float t = (Float) animation.getAnimatedValue();
                dispatchOnLauncherTransitionStep(fromView, t);
                dispatchOnLauncherTransitionStep(toView, t);
            }
        });
        // toView should appear right at the end of the workspace shrink
        // animation
        mStateAnimation = LauncherAnimUtils.createAnimatorSet();
        mStateAnimation.play(scaleAnim).after(startDelay);
        mStateAnimation.play(alphaAnim).after(startDelay);
        mStateAnimation.addListener(new AnimatorListenerAdapter() {

            boolean animationCancelled = false;

            @Override
            public void onAnimationStart(Animator animation) {
                updateWallpaperVisibility(true);
                // Prepare the position
                toView.setTranslationX(0.0f);
                toView.setTranslationY(0.0f);
                toView.setVisibility(View.VISIBLE);
                toView.bringToFront();
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                dispatchOnLauncherTransitionEnd(fromView, animated, false);
                dispatchOnLauncherTransitionEnd(toView, animated, false);
                if (mWorkspace != null && !springLoaded && !LauncherApplication.isScreenLarge()) {
                    // Hide the workspace scrollbar
                    mWorkspace.hideScrollingIndicator(true);
                }
                if (!animationCancelled) {
                    updateWallpaperVisibility(false);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                animationCancelled = true;
            }
        });
        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }
        boolean delayAnim = false;
        final ViewTreeObserver observer;
        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        // yet, delay the animation until we get a layout pass
        if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) || (mWorkspace.getMeasuredWidth() == 0) || (toView.getMeasuredWidth() == 0)) {
            observer = mWorkspace.getViewTreeObserver();
            delayAnim = true;
        } else {
            observer = null;
        }
        final AnimatorSet stateAnimation = mStateAnimation;
        final Runnable startAnimRunnable = new Runnable() {

            public void run() {
                // we waited for a layout/draw pass
                if (mStateAnimation != stateAnimation)
                    return;
                setPivotsForZoom(toView, scale);
                dispatchOnLauncherTransitionStart(fromView, animated, false);
                dispatchOnLauncherTransitionStart(toView, animated, false);
                toView.post(new Runnable() {

                    public void run() {
                        // we waited for a layout/draw pass
                        if (mStateAnimation != stateAnimation)
                            return;
                        mStateAnimation.start();
                    }
                });
            }
        };
        if (delayAnim) {
            final OnGlobalLayoutListener delayedStart = new OnGlobalLayoutListener() {

                public void onGlobalLayout() {
                    toView.post(startAnimRunnable);
                    observer.removeOnGlobalLayoutListener(this);
                }
            };
            observer.addOnGlobalLayoutListener(delayedStart);
        } else {
            startAnimRunnable.run();
        }
    } else {
        toView.setTranslationX(0.0f);
        toView.setTranslationY(0.0f);
        toView.setScaleX(1.0f);
        toView.setScaleY(1.0f);
        toView.setVisibility(View.VISIBLE);
        toView.bringToFront();
        if (!springLoaded && !LauncherApplication.isScreenLarge()) {
            // Hide the workspace scrollbar
            mWorkspace.hideScrollingIndicator(true);
        }
        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionStart(fromView, animated, false);
        dispatchOnLauncherTransitionEnd(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        dispatchOnLauncherTransitionStart(toView, animated, false);
        dispatchOnLauncherTransitionEnd(toView, animated, false);
        updateWallpaperVisibility(false);
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) AnimatorSet(android.animation.AnimatorSet) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Resources(android.content.res.Resources) ViewTreeObserver(android.view.ViewTreeObserver)

Example 73 with AnimatorSet

use of android.animation.AnimatorSet in project LuaViewSDK by alibaba.

the class UDAnimatorSet method build.

/**
     * build a copy of given animator
     *
     * @return
     */
public Animator build() {
    final AnimatorSet animatorSet = getAnimatorSet();
    //克隆一份
    final AnimatorSet result = animatorSet.clone();
    setup(result);
    return result;
}
Also used : AnimatorSet(android.animation.AnimatorSet)

Example 74 with AnimatorSet

use of android.animation.AnimatorSet in project LuaViewSDK by alibaba.

the class UDAnimatorSet method cancel.

/**
     * cancel animator
     *
     * @return
     */
public UDAnimatorSet cancel() {
    final AnimatorSet animatorSet = getAnimatorSet();
    if (animatorSet != null) {
        if (animatorSet.isStarted()) {
            animatorSet.cancel();
            animatorSet.setupEndValues();
        }
    }
    if (mTarget != null) {
        mTarget.cancelAnimation();
    }
    return this;
}
Also used : AnimatorSet(android.animation.AnimatorSet)

Example 75 with AnimatorSet

use of android.animation.AnimatorSet in project LuaViewSDK by alibaba.

the class UDAnimatorSet method setupValues.

public UDAnimatorSet setupValues(Animator animator) {
    animator.setupStartValues();
    if (mTarget != null && mAnimators != null) {
        for (Animator anim : mAnimators) {
            anim.setTarget(mTarget.getView());
            anim.setupStartValues();
            if (anim instanceof ValueAnimator) {
                ((ValueAnimator) anim).setRepeatCount(mRepeatCount);
                ((ValueAnimator) anim).setRepeatMode(mRepeatMode);
            //TODO
            }
        }
        if (animator instanceof AnimatorSet) {
            ((AnimatorSet) animator).playTogether(mAnimators);
        }
    }
    return this;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator)

Aggregations

AnimatorSet (android.animation.AnimatorSet)491 ObjectAnimator (android.animation.ObjectAnimator)343 Animator (android.animation.Animator)285 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)144 View (android.view.View)109 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)50 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)26 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 Bitmap (android.graphics.Bitmap)17 Point (android.graphics.Point)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)14