Search in sources :

Example 96 with ObjectAnimator

use of android.animation.ObjectAnimator in project FlyRefresh by race604.

the class FlyRefreshLayout method startRefresh.

@Override
public void startRefresh() {
    if (mFlyAnimator != null) {
        mFlyAnimator.end();
    }
    final View iconView = getIconView();
    UIUtils.clearAnimator(iconView);
    AnimatorSet flyUpAnim = new AnimatorSet();
    flyUpAnim.setDuration(800);
    ObjectAnimator transX = ObjectAnimator.ofFloat(iconView, "translationX", 0, getWidth());
    ObjectAnimator transY = ObjectAnimator.ofFloat(iconView, "translationY", 0, -mHeaderController.getHeight());
    transY.setInterpolator(PathInterpolatorCompat.create(0.7f, 1f));
    ObjectAnimator rotation = ObjectAnimator.ofFloat(iconView, "rotation", -45, 0);
    rotation.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator rotationX = ObjectAnimator.ofFloat(iconView, "rotationX", 0, 60);
    rotationX.setInterpolator(new DecelerateInterpolator());
    flyUpAnim.playTogether(transX, transY, rotationX, ObjectAnimator.ofFloat(iconView, "scaleX", 1, 0.5f), ObjectAnimator.ofFloat(iconView, "scaleY", 1, 0.5f), rotation);
    mFlyAnimator = flyUpAnim;
    mFlyAnimator.start();
    if (mListener != null) {
        mListener.onRefresh(FlyRefreshLayout.this);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) MountanScenceView(com.race604.flyrefresh.internal.MountanScenceView)

Example 97 with ObjectAnimator

use of android.animation.ObjectAnimator in project FloatingSearchView by renaudcerrato.

the class FloatingSearchView method fadeIn.

private void fadeIn(boolean enter) {
    ValueAnimator backgroundAnim;
    if (Build.VERSION.SDK_INT >= 19)
        backgroundAnim = ObjectAnimator.ofInt(mBackgroundDrawable, "alpha", enter ? 255 : 0);
    else {
        backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0);
        backgroundAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int value = (Integer) animation.getAnimatedValue();
                mBackgroundDrawable.setAlpha(value);
            }
        });
    }
    backgroundAnim.setDuration(enter ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT);
    backgroundAnim.setInterpolator(enter ? DECELERATE : ACCELERATE);
    backgroundAnim.start();
    Drawable icon = unwrap(getIcon());
    if (icon != null) {
        ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0);
        iconAnim.setDuration(backgroundAnim.getDuration());
        iconAnim.setInterpolator(backgroundAnim.getInterpolator());
        iconAnim.start();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ValueAnimator(android.animation.ValueAnimator)

Example 98 with ObjectAnimator

use of android.animation.ObjectAnimator in project ToggleDrawable by renaudcerrato.

the class MainActivity method toggle.

private void toggle() {
    isFaded = !isFaded;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        AnimatorSet set = new AnimatorSet();
        ObjectAnimator backgroundAnim = ObjectAnimator.ofInt(mContainer.getBackground(), "alpha", isFaded ? 128 : 0);
        ObjectAnimator drawableAnim = ObjectAnimator.ofInt(mSeekBar, "progress", isFaded ? mSeekBar.getMax() : 0);
        set.setDuration(700);
        set.setInterpolator(new DecelerateInterpolator(3f));
        set.playTogether(backgroundAnim, drawableAnim);
        set.start();
    } else {
        Animation set = new ToggleAnimationSet(isFaded);
        set.setDuration(700);
        set.setInterpolator(new DecelerateInterpolator(3f));
        mContainer.startAnimation(set);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Animation(android.view.animation.Animation) AnimatorSet(android.animation.AnimatorSet)

Example 99 with ObjectAnimator

use of android.animation.ObjectAnimator in project robolectric by robolectric.

the class ShadowObjectAnimatorTest method start_shouldRunAnimation.

@Test
public void start_shouldRunAnimation() {
    final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4);
    Robolectric.getForegroundThreadScheduler().pause();
    animator.setDuration(1000);
    animator.addListener(listener);
    animator.start();
    verify(listener).onAnimationStart(animator);
    assertThat(target.getTransparency()).isEqualTo(0);
    Robolectric.flushForegroundThreadScheduler();
    verify(listener).onAnimationEnd(animator);
    assertThat(target.getTransparency()).isEqualTo(4);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Test(org.junit.Test)

Example 100 with ObjectAnimator

use of android.animation.ObjectAnimator in project muzei by romannurik.

the class MuzeiActivity method updateUiMode.

private void updateUiMode() {
    // TODO: this should really just use fragment transactions and transitions
    int newUiMode = UI_MODE_INTRO;
    if (mWallpaperActive) {
        newUiMode = UI_MODE_TUTORIAL;
        if (mSeenTutorial) {
            newUiMode = UI_MODE_ART_DETAIL;
        }
    }
    if (mUiMode == newUiMode) {
        return;
    }
    // Crossfade between main containers
    final View oldContainerView = getMainContainerForUiMode(mUiMode);
    final View newContainerView = getMainContainerForUiMode(newUiMode);
    if (oldContainerView != null) {
        oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() {

            @Override
            public void run() {
                oldContainerView.setVisibility(View.GONE);
            }
        });
    }
    if (newContainerView != null) {
        if (newContainerView.getAlpha() == 1) {
            newContainerView.setAlpha(0);
        }
        newContainerView.setVisibility(View.VISIBLE);
        newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null);
    }
    // Special work
    if (newUiMode == UI_MODE_INTRO) {
        FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.TUTORIAL_BEGIN, null);
        final View activateButton = findViewById(R.id.activate_muzei_button);
        activateButton.setAlpha(0);
        final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager().findFragmentById(R.id.animated_logo_fragment);
        logoFragment.reset();
        logoFragment.setOnFillStartedCallback(new Runnable() {

            @Override
            public void run() {
                activateButton.animate().alpha(1f).setDuration(500);
            }
        });
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                logoFragment.start();
            }
        }, 1000);
    }
    if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) {
        FragmentManager fm = getSupportFragmentManager();
        Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container);
        if (newUiMode == UI_MODE_INTRO && demoFragment == null) {
            fm.beginTransaction().add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit();
        } else if (newUiMode != UI_MODE_INTRO && demoFragment != null) {
            fm.beginTransaction().remove(demoFragment).commit();
        }
    }
    if (newUiMode == UI_MODE_TUTORIAL) {
        float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics());
        View mainTextView = findViewById(R.id.tutorial_main_text);
        mainTextView.setAlpha(0);
        mainTextView.setTranslationY(-animateDistance / 5);
        View subTextView = findViewById(R.id.tutorial_sub_text);
        subTextView.setAlpha(0);
        subTextView.setTranslationY(-animateDistance / 5);
        final View affordanceView = findViewById(R.id.tutorial_icon_affordance);
        affordanceView.setAlpha(0);
        affordanceView.setTranslationY(animateDistance);
        View iconTextView = findViewById(R.id.tutorial_icon_text);
        iconTextView.setAlpha(0);
        iconTextView.setTranslationY(animateDistance);
        AnimatorSet set = new AnimatorSet();
        set.setStartDelay(500);
        set.setDuration(250);
        set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f));
        set.start();
        set = new AnimatorSet();
        set.setStartDelay(2000);
        // Bug in older versions where set.setInterpolator didn't work
        Interpolator interpolator = new OvershootInterpolator();
        ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0);
        ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0);
        a1.setInterpolator(interpolator);
        a2.setInterpolator(interpolator);
        a3.setInterpolator(interpolator);
        a4.setInterpolator(interpolator);
        set.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            set.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate);
                    AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme());
                    emanateView.setImageDrawable(avd);
                    avd.start();
                }
            });
        }
        set.start();
    }
    if (newUiMode == UI_MODE_ART_DETAIL) {
        FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.TUTORIAL_COMPLETE, null);
    }
    mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE);
    mUiMode = newUiMode;
    maybeUpdateArtDetailOpenedClosed();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) View(android.view.View) AnimatedMuzeiLoadingSpinnerView(com.google.android.apps.muzei.util.AnimatedMuzeiLoadingSpinnerView) TextView(android.widget.TextView) PanScaleProxyView(com.google.android.apps.muzei.util.PanScaleProxyView) AnimatedMuzeiLogoFragment(com.google.android.apps.muzei.util.AnimatedMuzeiLogoFragment) Fragment(android.support.v4.app.Fragment) AnimatedMuzeiLogoFragment(com.google.android.apps.muzei.util.AnimatedMuzeiLogoFragment) MuzeiRendererFragment(com.google.android.apps.muzei.render.MuzeiRendererFragment) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) FragmentManager(android.support.v4.app.FragmentManager) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ImageView(android.widget.ImageView)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)767 Animator (android.animation.Animator)304 AnimatorSet (android.animation.AnimatorSet)209 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)202 PropertyValuesHolder (android.animation.PropertyValuesHolder)125 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)99 Paint (android.graphics.Paint)68 TextView (android.widget.TextView)47 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)46 ViewGroup (android.view.ViewGroup)45 LinearInterpolator (android.view.animation.LinearInterpolator)36 Rect (android.graphics.Rect)34 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)28 OvershootInterpolator (android.view.animation.OvershootInterpolator)27 ArrayList (java.util.ArrayList)21 Interpolator (android.view.animation.Interpolator)20 TargetApi (android.annotation.TargetApi)19