Search in sources :

Example 1 with ObjectAnimator

use of android.animation.ObjectAnimator in project cw-omnibus by commonsguy.

the class MainActivity method animateMarker.

private void animateMarker() {
    map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 48));
    Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
    ObjectAnimator animator = ObjectAnimator.ofObject(markerToAnimate, property, new LatLngEvaluator(), nextAnimationEnd);
    animator.setDuration(2000);
    animator.start();
    if (nextAnimationEnd == LINCOLN_CENTER) {
        nextAnimationEnd = PENN_STATION;
    } else {
        nextAnimationEnd = LINCOLN_CENTER;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Marker(com.google.android.gms.maps.model.Marker) LatLng(com.google.android.gms.maps.model.LatLng)

Example 2 with ObjectAnimator

use of android.animation.ObjectAnimator in project kickmaterial by byoutline.

the class CategoriesListActivity method runFinishAnimation.

private void runFinishAnimation(Runnable finishAction) {
    if (summaryScrolledValue > 0) {
        binding.categoriesRv.smoothScrollToPosition(0);
    }
    ViewUtils.showView(binding.selectCategoryTv, false);
    ObjectAnimator imageFade = ObjectAnimator.ofFloat(binding.selectedCategoryIv, View.ALPHA, 1, 0);
    AnimatorSet set = new AnimatorSet();
    AnimatorSet closeButtonScale = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 1, 0.1f);
    set.playTogether(closeButtonScale, imageFade);
    set.setDuration(FINISH_ANIMATION_DURATION);
    set.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (revealAnimation != null) {
                revealAnimation.cancel();
            }
            ViewUtils.showView(binding.categoryCircleRevealIv, false);
            binding.closeCategoriesIv.setScaleX(0);
            binding.closeCategoriesIv.setScaleY(0);
            finishAction.run();
        }
    });
    binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_to_bottom));
    set.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Example 3 with ObjectAnimator

use of android.animation.ObjectAnimator in project cw-omnibus by commonsguy.

the class AsyncDemoFragment method changeMenuIconAnimation.

// based on https://goo.gl/3IUM8K
private void changeMenuIconAnimation(final FloatingActionMenu menu) {
    AnimatorSet set = new AnimatorSet();
    final ImageView v = menu.getMenuIconView();
    ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f);
    ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f);
    ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f);
    ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f);
    scaleOutX.setDuration(50);
    scaleOutY.setDuration(50);
    scaleInX.setDuration(150);
    scaleInY.setDuration(150);
    scaleInX.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            v.setImageResource(menu.isOpened() ? R.drawable.ic_action_settings : R.drawable.ic_close);
        }
    });
    set.play(scaleOutX).with(scaleOutY);
    set.play(scaleInX).with(scaleInY).after(scaleOutX);
    set.setInterpolator(new OvershootInterpolator(2));
    menu.setIconToggleAnimatorSet(set);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView)

Example 4 with ObjectAnimator

use of android.animation.ObjectAnimator in project Launcher3 by chislon.

the class LauncherTransitionable method showAppsCustomizeHelper.

private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded, final AppsCustomizePagedView.ContentType contentType) {
    if (mStateAnimation != null) {
        mStateAnimation.setDuration(0);
        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 (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
        // Set the content type for the all apps space
        mAppsCustomizeTabHost.setContentTypeImmediate(contentType);
    }
    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 = LauncherAnimUtils.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() {

            @Override
            public void onAnimationStart(Animator animation) {
                // 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);
                // Hide the search bar
                if (mSearchDropTargetBar != null) {
                    mSearchDropTargetBar.hideSearchBar(false);
                }
            }
        });
        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }
        boolean delayAnim = false;
        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)) {
            delayAnim = true;
        }
        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);
                LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView);
            }
        };
        if (delayAnim) {
            final ViewTreeObserver observer = toView.getViewTreeObserver();
            observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

                public void onGlobalLayout() {
                    startAnimRunnable.run();
                    toView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
            });
        } 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 && !LauncherAppState.getInstance().isScreenLarge()) {
            // Hide the search bar
            if (mSearchDropTargetBar != null) {
                mSearchDropTargetBar.hideSearchBar(false);
            }
        }
        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionStart(fromView, animated, false);
        dispatchOnLauncherTransitionEnd(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        dispatchOnLauncherTransitionStart(toView, animated, false);
        dispatchOnLauncherTransitionEnd(toView, animated, 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) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Point(android.graphics.Point) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Resources(android.content.res.Resources) ViewTreeObserver(android.view.ViewTreeObserver)

Example 5 with ObjectAnimator

use of android.animation.ObjectAnimator in project Launcher3 by chislon.

the class LauncherAnimUtils method ofPropertyValuesHolder.

public static ObjectAnimator ofPropertyValuesHolder(Object target, View view, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, view);
    return anim;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

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