Search in sources :

Example 66 with ObjectAnimator

use of android.animation.ObjectAnimator in project ExpectAnim by florent37.

the class TextColorAnimExpectation method getAnimator.

@Override
public Animator getAnimator(View viewToMove) {
    if (viewToMove instanceof TextView) {
        final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(viewToMove, "textColor", ((TextView) viewToMove).getCurrentTextColor(), textColor);
        objectAnimator.setEvaluator(new ArgbEvaluator());
        return objectAnimator;
    } else {
        return null;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) TextView(android.widget.TextView)

Example 67 with ObjectAnimator

use of android.animation.ObjectAnimator in project android-floating-action-button by futuresimple.

the class FloatingActionsMenu method createAddButton.

private void createAddButton(Context context) {
    mAddButton = new AddFloatingActionButton(context) {

        @Override
        void updateBackground() {
            mPlusColor = mAddButtonPlusColor;
            mColorNormal = mAddButtonColorNormal;
            mColorPressed = mAddButtonColorPressed;
            mStrokeVisible = mAddButtonStrokeVisible;
            super.updateBackground();
        }

        @Override
        Drawable getIconDrawable() {
            final RotatingDrawable rotatingDrawable = new RotatingDrawable(super.getIconDrawable());
            mRotatingDrawable = rotatingDrawable;
            final OvershootInterpolator interpolator = new OvershootInterpolator();
            final ObjectAnimator collapseAnimator = ObjectAnimator.ofFloat(rotatingDrawable, "rotation", EXPANDED_PLUS_ROTATION, COLLAPSED_PLUS_ROTATION);
            final ObjectAnimator expandAnimator = ObjectAnimator.ofFloat(rotatingDrawable, "rotation", COLLAPSED_PLUS_ROTATION, EXPANDED_PLUS_ROTATION);
            collapseAnimator.setInterpolator(interpolator);
            expandAnimator.setInterpolator(interpolator);
            mExpandAnimation.play(expandAnimator);
            mCollapseAnimation.play(collapseAnimator);
            return rotatingDrawable;
        }
    };
    mAddButton.setId(R.id.fab_expand_menu_button);
    mAddButton.setSize(mAddButtonSize);
    mAddButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            toggle();
        }
    });
    addView(mAddButton, super.generateDefaultLayoutParams());
    mButtonsCount++;
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) View(android.view.View)

Example 68 with ObjectAnimator

use of android.animation.ObjectAnimator in project XobotOS by xamarin.

the class ActionBarContextView method makeInAnimation.

private Animator makeInAnimation() {
    mClose.setTranslationX(-mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0);
    buttonAnimator.setDuration(200);
    buttonAnimator.addListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());
    AnimatorSet set = new AnimatorSet();
    AnimatorSet.Builder b = set.play(buttonAnimator);
    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = count - 1, j = 0; i >= 0; i--, j++) {
                View child = mMenuView.getChildAt(i);
                child.setScaleY(0);
                ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1);
                a.setDuration(100);
                a.setStartDelay(j * 70);
                b.with(a);
            }
        }
    }
    return set;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ActionMenuView(com.android.internal.view.menu.ActionMenuView) TextView(android.widget.TextView) View(android.view.View)

Example 69 with ObjectAnimator

use of android.animation.ObjectAnimator in project TourGuide by worker8.

the class TourGuide method performAnimationOn.

private void performAnimationOn(final View view) {
    if (mTechnique != null && mTechnique == Technique.HORIZONTAL_LEFT) {
        final AnimatorSet animatorSet = new AnimatorSet();
        final AnimatorSet animatorSet2 = new AnimatorSet();
        Animator.AnimatorListener lis1 = new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                view.setScaleX(1f);
                view.setScaleY(1f);
                view.setTranslationX(0);
                animatorSet2.start();
            }
        };
        Animator.AnimatorListener lis2 = new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                view.setScaleX(1f);
                view.setScaleY(1f);
                view.setTranslationX(0);
                animatorSet.start();
            }
        };
        long fadeInDuration = 800;
        long scaleDownDuration = 800;
        long goLeftXDuration = 2000;
        long fadeOutDuration = goLeftXDuration;
        float translationX = getScreenWidth() / 2;
        final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
        fadeInAnim.setDuration(fadeInDuration);
        final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
        scaleDownX.setDuration(scaleDownDuration);
        final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
        scaleDownY.setDuration(scaleDownDuration);
        final ObjectAnimator goLeftX = ObjectAnimator.ofFloat(view, "translationX", -translationX);
        goLeftX.setDuration(goLeftXDuration);
        final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
        fadeOutAnim.setDuration(fadeOutDuration);
        final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
        fadeInAnim2.setDuration(fadeInDuration);
        final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
        scaleDownX2.setDuration(scaleDownDuration);
        final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
        scaleDownY2.setDuration(scaleDownDuration);
        final ObjectAnimator goLeftX2 = ObjectAnimator.ofFloat(view, "translationX", -translationX);
        goLeftX2.setDuration(goLeftXDuration);
        final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
        fadeOutAnim2.setDuration(fadeOutDuration);
        animatorSet.play(fadeInAnim);
        animatorSet.play(scaleDownX).with(scaleDownY).after(fadeInAnim);
        animatorSet.play(goLeftX).with(fadeOutAnim).after(scaleDownY);
        animatorSet2.play(fadeInAnim2);
        animatorSet2.play(scaleDownX2).with(scaleDownY2).after(fadeInAnim2);
        animatorSet2.play(goLeftX2).with(fadeOutAnim2).after(scaleDownY2);
        animatorSet.addListener(lis1);
        animatorSet2.addListener(lis2);
        animatorSet.start();
        /* these animatorSets are kept track in FrameLayout, so that they can be cleaned up when FrameLayout is detached from window */
        mFrameLayout.addAnimatorSet(animatorSet);
        mFrameLayout.addAnimatorSet(animatorSet2);
    } else if (mTechnique != null && mTechnique == Technique.HORIZONTAL_RIGHT) {
    //TODO: new feature
    } else if (mTechnique != null && mTechnique == Technique.VERTICAL_UPWARD) {
    //TODO: new feature
    } else if (mTechnique != null && mTechnique == Technique.VERTICAL_DOWNWARD) {
    //TODO: new feature
    } else {
        // do click for default case
        final AnimatorSet animatorSet = new AnimatorSet();
        final AnimatorSet animatorSet2 = new AnimatorSet();
        Animator.AnimatorListener lis1 = new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                view.setScaleX(1f);
                view.setScaleY(1f);
                view.setTranslationX(0);
                animatorSet2.start();
            }
        };
        Animator.AnimatorListener lis2 = new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                view.setScaleX(1f);
                view.setScaleY(1f);
                view.setTranslationX(0);
                animatorSet.start();
            }
        };
        long fadeInDuration = 800;
        long scaleDownDuration = 800;
        long fadeOutDuration = 800;
        long delay = 1000;
        final ValueAnimator delayAnim = ObjectAnimator.ofFloat(view, "translationX", 0);
        delayAnim.setDuration(delay);
        final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
        fadeInAnim.setDuration(fadeInDuration);
        final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
        scaleDownX.setDuration(scaleDownDuration);
        final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
        scaleDownY.setDuration(scaleDownDuration);
        final ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
        scaleUpX.setDuration(scaleDownDuration);
        final ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
        scaleUpY.setDuration(scaleDownDuration);
        final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
        fadeOutAnim.setDuration(fadeOutDuration);
        final ValueAnimator delayAnim2 = ObjectAnimator.ofFloat(view, "translationX", 0);
        delayAnim2.setDuration(delay);
        final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
        fadeInAnim2.setDuration(fadeInDuration);
        final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
        scaleDownX2.setDuration(scaleDownDuration);
        final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
        scaleDownY2.setDuration(scaleDownDuration);
        final ObjectAnimator scaleUpX2 = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
        scaleUpX2.setDuration(scaleDownDuration);
        final ObjectAnimator scaleUpY2 = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
        scaleUpY2.setDuration(scaleDownDuration);
        final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
        fadeOutAnim2.setDuration(fadeOutDuration);
        view.setAlpha(0);
        animatorSet.setStartDelay(mToolTip != null ? mToolTip.mEnterAnimation.getDuration() : 0);
        animatorSet.play(fadeInAnim);
        animatorSet.play(scaleDownX).with(scaleDownY).after(fadeInAnim);
        animatorSet.play(scaleUpX).with(scaleUpY).with(fadeOutAnim).after(scaleDownY);
        animatorSet.play(delayAnim).after(scaleUpY);
        animatorSet2.play(fadeInAnim2);
        animatorSet2.play(scaleDownX2).with(scaleDownY2).after(fadeInAnim2);
        animatorSet2.play(scaleUpX2).with(scaleUpY2).with(fadeOutAnim2).after(scaleDownY2);
        animatorSet2.play(delayAnim2).after(scaleUpY2);
        animatorSet.addListener(lis1);
        animatorSet2.addListener(lis2);
        animatorSet.start();
        /* these animatorSets are kept track in FrameLayout, so that they can be cleaned up when FrameLayout is detached from window */
        mFrameLayout.addAnimatorSet(animatorSet);
        mFrameLayout.addAnimatorSet(animatorSet2);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator)

Example 70 with ObjectAnimator

use of android.animation.ObjectAnimator in project ViewInspector by xfumihiro.

the class ViewInspectorToolbar method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    mToolbar = findViewById(R.id.toolbar);
    mToggleButton = (ImageButton) findViewById(R.id.toggle_menu);
    ImageButton buttonBoundaryMenu = (ImageButton) findViewById(R.id.outline_menu);
    ImageButton buttonLayerMenu = (ImageButton) findViewById(R.id.layer_menu);
    ImageButton buttonEventMenu = (ImageButton) findViewById(R.id.event_menu);
    ImageButton buttonSettingsMenu = (ImageButton) findViewById(R.id.settings_menu);
    mToolbar.setTranslationX(mToolbarWidth);
    ObjectAnimator animator = ObjectAnimator.ofFloat(mToolbar, "translationX", mToolbarWidth, mToolbarWidth - mToolbarClosedWidth);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.start();
    mToggleButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            closeMenu();
            toggleToolbar();
        }
    });
    buttonBoundaryMenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!(mMenu instanceof BoundaryMenu)) {
                closeMenu();
                mMenu = new BoundaryMenu(mContext);
                windowManager.addView(mMenu, BaseMenu.createLayoutParams(mContext));
            } else {
                closeMenu();
            }
        }
    });
    buttonLayerMenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!(mMenu instanceof LayerMenu)) {
                closeMenu();
                mMenu = new LayerMenu(mContext);
                windowManager.addView(mMenu, BaseMenu.createLayoutParams(mContext));
            } else {
                closeMenu();
            }
        }
    });
    buttonEventMenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!(mMenu instanceof EventMenu)) {
                closeMenu();
                mMenu = new EventMenu(mContext);
                windowManager.addView(mMenu, BaseMenu.createLayoutParams(mContext));
            } else {
                closeMenu();
            }
        }
    });
    buttonSettingsMenu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!(mMenu instanceof SettingsMenu)) {
                closeMenu();
                mMenu = new SettingsMenu(mContext);
                windowManager.addView(mMenu, BaseMenu.createLayoutParams(mContext));
            } else {
                closeMenu();
            }
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ImageButton(android.widget.ImageButton) SettingsMenu(view_inspector.ui.menu.SettingsMenu) ObjectAnimator(android.animation.ObjectAnimator) EventMenu(view_inspector.ui.menu.EventMenu) LayerMenu(view_inspector.ui.menu.LayerMenu) View(android.view.View) BoundaryMenu(view_inspector.ui.menu.BoundaryMenu)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)791 Animator (android.animation.Animator)313 AnimatorSet (android.animation.AnimatorSet)214 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)208 PropertyValuesHolder (android.animation.PropertyValuesHolder)128 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)102 Paint (android.graphics.Paint)68 TextView (android.widget.TextView)49 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)48 ViewGroup (android.view.ViewGroup)45 Rect (android.graphics.Rect)35 LinearInterpolator (android.view.animation.LinearInterpolator)35 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)29 OvershootInterpolator (android.view.animation.OvershootInterpolator)29 ArrayList (java.util.ArrayList)22 TargetApi (android.annotation.TargetApi)21 Interpolator (android.view.animation.Interpolator)20