Example usage for android.animation AnimatorSet play

List of usage examples for android.animation AnimatorSet play

Introduction

In this page you can find the example usage for android.animation AnimatorSet play.

Prototype

public Builder play(Animator anim) 

Source Link

Document

This method creates a Builder object, which is used to set up playing constraints.

Usage

From source file:support.plus.reportit.rv.FragmentActivity.java

private void createCustomAnimation() {
    final FloatingActionMenu menu3 = (FloatingActionMenu) findViewById(R.id.menuShareReport);

    AnimatorSet set = new AnimatorSet();

    ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleX", 1.0f, 0.2f);
    ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleY", 1.0f, 0.2f);

    ObjectAnimator scaleInX = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleX", 0.2f, 1.0f);
    ObjectAnimator scaleInY = ObjectAnimator.ofFloat(menu3.getMenuIconView(), "scaleY", 0.2f, 1.0f);

    scaleOutX.setDuration(50);//from  w ww . ja v a 2s.  c  o  m
    scaleOutY.setDuration(50);

    scaleInX.setDuration(150);
    scaleInY.setDuration(150);

    scaleInX.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            menu3.getMenuIconView().setImageResource(
                    menu3.isOpened() ? R.drawable.ic_unarchive_white_24dp : R.drawable.ic_done_white_24dp);
        }
    });

    set.play(scaleOutX).with(scaleOutY);
    set.play(scaleInX).with(scaleInY).after(scaleOutX);
    set.setInterpolator(new OvershootInterpolator(2));

    menu3.setIconToggleAnimatorSet(set);
}

From source file:com.example.waitou.rxjava.LoadingView.java

/**
 * build FlexibleAnimation to control the progress
 *
 * @return Animatorset for control the progress
 *///from  ww  w . ja  v a2 s  .co  m
private AnimatorSet buildFlexibleAnimation() {
    final Ring ring = mRing;
    AnimatorSet set = new AnimatorSet();
    ValueAnimator increment = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC)
            .setDuration(ANIMATOR_DURATION / 2);
    increment.setInterpolator(new LinearInterpolator());
    increment.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float sweeping = ring.sweeping;
            final float value = (float) animation.getAnimatedValue();
            ring.sweep = sweeping + value;
            invalidate();
        }
    });
    increment.addListener(animatorListener);
    ValueAnimator reduce = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC)
            .setDuration(ANIMATOR_DURATION / 2);
    reduce.setInterpolator(interpolator);
    reduce.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float sweeping = ring.sweeping;
            float starting = ring.starting;
            float value = (float) animation.getAnimatedValue();
            ring.sweep = sweeping - value;
            ring.start = starting + value;
        }
    });
    set.play(reduce).after(increment);
    return set;
}

From source file:com.betterAlarm.deskclock.timer.TimerFragment.java

private Animator getScaleFooterButtonsAnimator(final boolean show) {
    final AnimatorSet animatorSet = new AnimatorSet();
    final Animator leftButtonAnimator = AnimatorUtils.getScaleAnimator(mLeftButton, show ? 0.0f : 1.0f,
            show ? 1.0f : 0.0f);/*from w  ww  . ja  v  a2 s. c o m*/
    final Animator rightButtonAnimator = AnimatorUtils.getScaleAnimator(mRightButton, show ? 0.0f : 1.0f,
            show ? 1.0f : 0.0f);
    final float fabStartScale = (show && mFab.getVisibility() == View.INVISIBLE) ? 0.0f : 1.0f;
    final Animator fabAnimator = AnimatorUtils.getScaleAnimator(mFab, fabStartScale, show ? 1.0f : 0.0f);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mLeftButton.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
            mRightButton.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
            restoreScale(mLeftButton);
            restoreScale(mRightButton);
            restoreScale(mFab);
        }
    });
    // If not show, means transiting from timer view to setup view,
    // when the setup view starts to rotate, the footer buttons are already invisible,
    // so the scaling has to finish before the setup view starts rotating
    animatorSet.setDuration(show ? ROTATE_ANIM_DURATION_MILIS * 2 : ROTATE_ANIM_DURATION_MILIS);
    animatorSet.play(leftButtonAnimator).with(rightButtonAnimator).with(fabAnimator);
    return animatorSet;
}

From source file:com.fairphone.fplauncher3.Folder.java

public void animateOpen() {
    if (!(getParent() instanceof DragLayer)) {
        return;/*from w  w w .j  a va 2s. c  om*/
    }

    Animator openFolderAnim;
    final Runnable onCompleteRunnable;
    if (!Utilities.isLmpOrAbove()) {
        positionAndSizeAsIcon();
        centerAboutIcon();

        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1f);
        PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
        PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
        final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
        oa.setDuration(mExpandDuration);
        openFolderAnim = oa;

        setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    } else {
        prepareReveal();
        centerAboutIcon();

        int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
        int height = getFolderHeight();

        float transX = -0.075f * (width / 2 - getPivotX());
        float transY = -0.075f * (height / 2 - getPivotY());
        final float endTransX = 0;
        final float endTransY = 0;

        setTranslationX(transX);
        setTranslationY(transY);
        PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX, endTransX);
        PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY, endTransY);

        int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX());
        int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY());
        float radius = (float) Math.sqrt(rx * rx + ry * ry);
        AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        Animator reveal = LauncherAnimUtils.createCircularReveal(this, (int) getPivotX(), (int) getPivotY(), 0,
                radius);
        reveal.setDuration(mMaterialExpandDuration);
        reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

        View[] alphaViewSet = new View[] { mContent, mFolderName };
        for (View view : alphaViewSet) {
            Animator alphaAnimator = setupAlphaAnimator(view, 0f, 1f, mMaterialExpandDuration,
                    mMaterialExpandStagger);
            anim.play(alphaAnimator);
        }

        /* mContent.setAlpha(0f);
         Animator iconsAlpha = LauncherAnimUtils.ofFloat(mContent, "alpha", 0f, 1f);
         iconsAlpha.setDuration(mMaterialExpandDuration);
         iconsAlpha.setStartDelay(mMaterialExpandStagger);
         iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
                
         mFolderName.setAlpha(0f);
         Animator textAlpha = LauncherAnimUtils.ofFloat(mFolderName, "alpha", 0f, 1f);
         textAlpha.setDuration(mMaterialExpandDuration);
         textAlpha.setStartDelay(mMaterialExpandStagger);
         textAlpha.setInterpolator(new AccelerateInterpolator(1.5f));*/

        Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty);
        drift.setDuration(mMaterialExpandDuration);
        drift.setStartDelay(mMaterialExpandStagger);
        drift.setInterpolator(new LogDecelerateInterpolator(60, 0));
        drift.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                // in low power mode the animation doesn't play, so set the end value here
                Folder.this.setTranslationX(endTransX);
                Folder.this.setTranslationY(endTransY);
            }
        });

        anim.play(drift);
        /* anim.play(iconsAlpha);
         anim.play(textAlpha);*/
        anim.play(reveal);

        openFolderAnim = anim;

        mContent.setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                mContent.setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    }
    openFolderAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(),
                            mContent.getCountY()));
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;

            if (onCompleteRunnable != null) {
                onCompleteRunnable.run();
            }

            setFocusOnFirstChild();
        }
    });
    openFolderAnim.start();

    // Make sure the folder picks up the last drag move even if the finger doesn't move.
    if (mDragController.isDragging()) {
        mDragController.forceTouchMove();
    }
}

From source file:com.android.launcher2.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState())
        return;/*w w w  .jav  a 2s  .co  m*/

    if (v instanceof PagedViewIcon) {
        // Animate some feedback to the click
        final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();

        // Lock the drawable state to pressed until we return to Launcher
        if (mPressedIcon != null) {
            mPressedIcon.lockDrawableState();
        }

        // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled
        // to be consistent.  So re-enable the flag here, and we will re-disable it as necessary
        // when Launcher resumes and we are still in AllApps.
        mLauncher.updateWallpaperVisibility(true);
        mLauncher.startActivitySafely(v, appInfo.intent, appInfo);

    } else if (v instanceof PagedViewWidget) {
        // Let the user know that they have to long press to add a widget
        if (mWidgetInstructionToast != null) {
            mWidgetInstructionToast.cancel();
        }
        mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
                Toast.LENGTH_SHORT);
        mWidgetInstructionToast.show();

        // Create a little animation to show that the widget can move
        float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
        final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
        AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
        ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
        tyuAnim.setDuration(125);
        ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
        tydAnim.setDuration(100);
        bounce.play(tyuAnim).before(tydAnim);
        bounce.setInterpolator(new AccelerateInterpolator());
        bounce.start();
    }
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState())
        return;//from   w  w w .j  a  v  a 2s. c om

    if (v instanceof PagedViewIcon) {
        // Animate some feedback to the click
        final AppInfo appInfo = (AppInfo) v.getTag();

        // Lock the drawable state to pressed until we return to Launcher
        if (mPressedIcon != null) {
            mPressedIcon.lockDrawableState();
        }
        mLauncher.startActivitySafely(v, appInfo.intent, appInfo);
        mLauncher.getStats().recordLaunch(appInfo.intent);
    } else if (v instanceof PagedViewWidget) {
        // Let the user know that they have to long press to add a widget
        if (mWidgetInstructionToast != null) {
            mWidgetInstructionToast.cancel();
        }
        mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
                Toast.LENGTH_SHORT);
        mWidgetInstructionToast.show();

        // Create a little animation to show that the widget can move
        float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
        final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
        AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
        ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
        tyuAnim.setDuration(125);
        ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
        tydAnim.setDuration(100);
        bounce.play(tyuAnim).before(tydAnim);
        bounce.setInterpolator(new AccelerateInterpolator());
        bounce.start();
    }
}

From source file:com.android.launcher3.Folder.java

public void animateOpen() {
    if (!(getParent() instanceof DragLayer))
        return;// ww w .  jav  a  2 s  .  c o  m

    Animator openFolderAnim = null;
    final Runnable onCompleteRunnable;
    if (!Utilities.isLmpOrAbove()) {
        positionAndSizeAsIcon();
        centerAboutIcon();

        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
        PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
        PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
        final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
        oa.setDuration(mExpandDuration);
        openFolderAnim = oa;

        setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    } else {
        prepareReveal();
        centerAboutIcon();

        int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
        int height = getFolderHeight();

        float transX = -0.075f * (width / 2 - getPivotX());
        float transY = -0.075f * (height / 2 - getPivotY());
        setTranslationX(transX);
        setTranslationY(transY);
        PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX, 0);
        PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY, 0);

        int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX());
        int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY());
        float radius = (float) Math.sqrt(rx * rx + ry * ry);
        AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        Animator reveal = LauncherAnimUtils.createCircularReveal(this, (int) getPivotX(), (int) getPivotY(), 0,
                radius);
        reveal.setDuration(mMaterialExpandDuration);
        reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

        mContent.setAlpha(0f);
        Animator iconsAlpha = LauncherAnimUtils.ofFloat(mContent, "alpha", 0f, 1f);
        iconsAlpha.setDuration(mMaterialExpandDuration);
        iconsAlpha.setStartDelay(mMaterialExpandStagger);
        iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        mFolderName.setAlpha(0f);
        Animator textAlpha = LauncherAnimUtils.ofFloat(mFolderName, "alpha", 0f, 1f);
        textAlpha.setDuration(mMaterialExpandDuration);
        textAlpha.setStartDelay(mMaterialExpandStagger);
        textAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty);
        drift.setDuration(mMaterialExpandDuration);
        drift.setStartDelay(mMaterialExpandStagger);
        drift.setInterpolator(new LogDecelerateInterpolator(60, 0));

        anim.play(drift);
        anim.play(iconsAlpha);
        anim.play(textAlpha);
        anim.play(reveal);

        openFolderAnim = anim;

        mContent.setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                mContent.setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    }
    openFolderAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(),
                            mContent.getCountY()));
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;

            if (onCompleteRunnable != null) {
                onCompleteRunnable.run();
            }

            setFocusOnFirstChild();
        }
    });
    openFolderAnim.start();

    // Make sure the folder picks up the last drag move even if the finger doesn't move.
    if (mDragController.isDragging()) {
        mDragController.forceTouchMove();
    }
}

From source file:com.zyk.launcher.AsyncTaskCallback.java

@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() || mLauncher.getWorkspace().isSwitchingState()
            || !(v instanceof PagedViewWidget))
        return;/*from ww  w.  jav  a  2  s.co m*/

    // Let the user know that they have to long press to add a widget
    if (mWidgetInstructionToast != null) {
        mWidgetInstructionToast.cancel();
    }
    mWidgetInstructionToast = Toast.makeText(getContext(), R.string.long_press_widget_to_add,
            Toast.LENGTH_SHORT);
    mWidgetInstructionToast.show();

    // Create a little animation to show that the widget can move
    float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
    final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
    AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
    ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
    tyuAnim.setDuration(125);
    ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
    tydAnim.setDuration(100);
    bounce.play(tyuAnim).before(tydAnim);
    bounce.setInterpolator(new AccelerateInterpolator());
    bounce.start();
}

From source file:com.android.launcher3.folder.Folder.java

public void animateOpen() {
    if (!(getParent() instanceof DragLayer))
        return;// w  ww. ja v a 2  s . c  om

    mContent.completePendingPageChanges();
    if (!mDragInProgress) {
        // Open on the first page.
        mContent.snapToPageImmediately(0);
    }

    // This is set to true in close(), but isn't reset to false until onDropCompleted(). This
    // leads to an inconsistent state if you drag out of the folder and drag back in without
    // dropping. One resulting issue is that replaceFolderWithFinalItem() can be called twice.
    mDeleteFolderOnDropCompleted = false;

    Animator openFolderAnim = null;
    final Runnable onCompleteRunnable;
    if (!Utilities.ATLEAST_LOLLIPOP) {
        positionAndSizeAsIcon();
        centerAboutIcon();

        final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 1, 1, 1);
        oa.setDuration(mExpandDuration);
        openFolderAnim = oa;

        setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    } else {
        prepareReveal();
        centerAboutIcon();

        AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
        int height = getFolderHeight();

        float transX = -0.075f * (width / 2 - getPivotX());
        float transY = -0.075f * (height / 2 - getPivotY());
        setTranslationX(transX);
        setTranslationY(transY);
        PropertyValuesHolder tx = PropertyValuesHolder.ofFloat(TRANSLATION_X, transX, 0);
        PropertyValuesHolder ty = PropertyValuesHolder.ofFloat(TRANSLATION_Y, transY, 0);

        Animator drift = ObjectAnimator.ofPropertyValuesHolder(this, tx, ty);
        drift.setDuration(mMaterialExpandDuration);
        drift.setStartDelay(mMaterialExpandStagger);
        drift.setInterpolator(new LogDecelerateInterpolator(100, 0));

        int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX());
        int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY());
        float radius = (float) Math.hypot(rx, ry);

        Animator reveal = new CircleRevealOutlineProvider((int) getPivotX(), (int) getPivotY(), 0, radius)
                .createRevealAnimator(this);
        reveal.setDuration(mMaterialExpandDuration);
        reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

        mContent.setAlpha(0f);
        Animator iconsAlpha = ObjectAnimator.ofFloat(mContent, "alpha", 0f, 1f);
        iconsAlpha.setDuration(mMaterialExpandDuration);
        iconsAlpha.setStartDelay(mMaterialExpandStagger);
        iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        mFooter.setAlpha(0f);
        Animator textAlpha = ObjectAnimator.ofFloat(mFooter, "alpha", 0f, 1f);
        textAlpha.setDuration(mMaterialExpandDuration);
        textAlpha.setStartDelay(mMaterialExpandStagger);
        textAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        anim.play(drift);
        anim.play(iconsAlpha);
        anim.play(textAlpha);
        anim.play(reveal);

        openFolderAnim = anim;

        mContent.setLayerType(LAYER_TYPE_HARDWARE, null);
        mFooter.setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                mContent.setLayerType(LAYER_TYPE_NONE, null);
                mFooter.setLayerType(LAYER_TYPE_NONE, null);
                mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
            }
        };
    }
    openFolderAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            Utilities.sendCustomAccessibilityEvent(Folder.this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    mContent.getAccessibilityDescription());
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;

            onCompleteRunnable.run();
            mContent.setFocusOnFirstChild();
        }
    });

    // Footer animation
    if (mContent.getPageCount() > 1 && !mInfo.hasOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION)) {
        int footerWidth = mContent.getDesiredWidth() - mFooter.getPaddingLeft() - mFooter.getPaddingRight();

        float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString());
        float translation = (footerWidth - textWidth) / 2;
        mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation);
        mPageIndicator.prepareEntryAnimation();

        // Do not update the flag if we are in drag mode. The flag will be updated, when we
        // actually drop the icon.
        final boolean updateAnimationFlag = !mDragInProgress;
        openFolderAnim.addListener(new AnimatorListenerAdapter() {

            @SuppressLint("InlinedApi")
            @Override
            public void onAnimationEnd(Animator animation) {
                mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION).translationX(0)
                        .setInterpolator(Utilities.ATLEAST_LOLLIPOP
                                ? AnimationUtils.loadInterpolator(mLauncher,
                                        android.R.interpolator.fast_out_slow_in)
                                : new LogDecelerateInterpolator(100, 0));
                mPageIndicator.playEntryAnimation();

                if (updateAnimationFlag) {
                    mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher);
                }
            }
        });
    } else {
        mFolderName.setTranslationX(0);
    }

    mPageIndicator.stopAllAnimations();
    openFolderAnim.start();

    // Make sure the folder picks up the last drag move even if the finger doesn't move.
    if (mDragController.isDragging()) {
        mDragController.forceTouchMove();
    }

    mContent.verifyVisibleHighResIcons(mContent.getNextPage());
}

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) {
    if (mState == state) {
        return null;
    }//  ww w .  ja v  a 2s.  c om

    // Initialize animation arrays for the first time if necessary
    initAnimationArrays();

    AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null;

    final State oldState = mState;
    final boolean oldStateIsNormal = (oldState == State.NORMAL);
    final boolean oldStateIsOverview = (oldState == State.OVERVIEW);
    setState(state);
    final boolean stateIsNormal = (state == State.NORMAL);
    final boolean stateIsOverview = (state == State.OVERVIEW);
    float finalBackgroundAlpha = stateIsOverview ? 1.0f : 0f;
    float finalPageIndicatorAlpha = stateIsOverview ? 0f : 1f;
    float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
    float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0;

    boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
    boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);

    mNewScale = 1.0f;

    if (state != State.NORMAL) {
        if (stateIsOverview) {
            mNewScale = mOverviewModeShrinkFactor;
        }
    }

    final int duration = getResources().getInteger(R.integer.config_overviewTransitionTime);

    for (int i = 0; i < getChildCount(); i++) {
        final CellLayout cl = (CellLayout) getChildAt(i);
        float finalAlpha = 1f;

        if (stateIsOverview) {
            cl.setVisibility(VISIBLE);
            cl.setTranslationX(0f);
            cl.setTranslationY(0f);
            cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
            cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
            cl.setRotation(0f);
            cl.setRotationY(0f);
            cl.setRotationX(0f);
            cl.setScaleX(1f);
            cl.setScaleY(1f);
            cl.setShortcutAndWidgetAlpha(1f);
        }

        mOldAlphas[i] = cl.getShortcutsAndWidgets().getAlpha();
        mNewAlphas[i] = finalAlpha;
        if (animated) {
            mOldBackgroundAlphas[i] = cl.getBackgroundAlpha();
            mNewBackgroundAlphas[i] = finalBackgroundAlpha;
        } else {
            cl.setBackgroundAlpha(finalBackgroundAlpha);
            cl.setShortcutAndWidgetAlpha(finalAlpha);
        }
    }

    final View overviewPanel = mLauncher.getOverviewPanel();
    if (animated) {
        anim.setDuration(duration);
        LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this);
        scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY)
                .setInterpolator(mZoomInInterpolator);
        anim.play(scale);
        ValueAnimator invalidate = ValueAnimator.ofFloat(0f, 1f);
        invalidate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                invalidate();
            }
        });
        anim.play(invalidate);
        ObjectAnimator pageIndicatorAlpha = null;
        if (getPageIndicator() != null) {
            pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalPageIndicatorAlpha);
        }
        ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha",
                finalOverviewPanelAlpha);

        overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));

        if (overviewToWorkspace) {
            overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2));
        }

        if (getPageIndicator() != null) {
            pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator()));
        }

        anim.play(overviewPanelAlpha);
        anim.play(pageIndicatorAlpha);

        for (int index = 0; index < getChildCount(); index++) {
            final int i = index;

            final CellLayout cl = (CellLayout) getChildAt(i);
            if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) {
                cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
                cl.getShortcutsAndWidgets().setAlpha(mNewAlphas[i]);
            } else {
                LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
                a.alpha(mNewAlphas[i]).setDuration(duration).setInterpolator(mZoomInInterpolator);
                anim.play(a);
                if (mOldBackgroundAlphas[i] != 0 || mNewBackgroundAlphas[i] != 0) {
                    ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f);
                    bgAnim.setInterpolator(mZoomInInterpolator);
                    bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
                        public void onAnimationUpdate(float a, float b) {
                            cl.setBackgroundAlpha(a * mOldBackgroundAlphas[i] + b * mNewBackgroundAlphas[i]);
                        }
                    });
                    anim.play(bgAnim);
                }
            }
        }

        anim.setStartDelay(delay);
    } else {
        overviewPanel.setAlpha(finalOverviewPanelAlpha);
        AlphaUpdateListener.updateVisibility(overviewPanel);
        if (getPageIndicator() != null) {
            getPageIndicator().setAlpha(finalPageIndicatorAlpha);
            AlphaUpdateListener.updateVisibility(getPageIndicator());
        }
        setScaleX(mNewScale);
        setScaleY(mNewScale);
        setTranslationY(finalWorkspaceTranslationY);
    }
    return anim;
}