Search in sources :

Example 91 with Animator

use of android.animation.Animator in project ShowcaseView by amlcurran.

the class AnimatorAnimationFactory method fadeOutView.

@Override
public void fadeOutView(View target, long duration, final AnimationEndListener listener) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
    oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animator) {
            listener.onAnimationEnd();
        }
    });
    oa.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 92 with Animator

use of android.animation.Animator in project ShowcaseView by amlcurran.

the class AnimatorAnimationFactory method fadeInView.

@Override
public void fadeInView(View target, long duration, final AnimationStartListener listener) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE, VISIBLE);
    oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animator) {
            listener.onAnimationStart();
        }
    });
    oa.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 93 with Animator

use of android.animation.Animator in project gdk-apidemo-sample by googleglass.

the class SliderActivity method processSliderRequest.

/**
     * Processes a request to show a slider.
     *
     * Starting a new Slider, regardless of its type, automatically hides any shown Slider.
     */
private void processSliderRequest(int position) {
    switch(position) {
        case SCROLLER:
            Slider.Scroller scroller = mSlider.startScroller(MAX_SLIDER_VALUE, 0);
            // Start an animation showing the different positions of the slider, the slider
            // automatically hides after a short time of inactivity.
            ObjectAnimator.ofFloat(scroller, "position", 0, MAX_SLIDER_VALUE).setDuration(ANIMATION_DURATION_MILLIS).start();
            break;
        case DETERMINATE:
            final Slider.Determinate determinate = mSlider.startDeterminate(MAX_SLIDER_VALUE, 0);
            ObjectAnimator animator = ObjectAnimator.ofFloat(determinate, "position", 0, MAX_SLIDER_VALUE);
            // Hide the slider when the animation stops.
            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    determinate.hide();
                }
            });
            // Start an animation showing the different positions of the slider.
            animator.setDuration(ANIMATION_DURATION_MILLIS).start();
            break;
        case GRACE_PERIOD:
            // Start the grace period slider and play a sound when one of the listener method
            // gets fired.
            mGracePeriod = mSlider.startGracePeriod(mGracePeriodListener);
            break;
        case INDETERMINATE:
            // Toggle between showing/hiding the indeterminate slider.
            if (mIndeterminate != null) {
                mIndeterminate.hide();
                mIndeterminate = null;
            } else {
                mIndeterminate = mSlider.startIndeterminate();
            }
            break;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) Scroller(com.google.android.glass.widget.Slider.Scroller) Slider(com.google.android.glass.widget.Slider) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Determinate(com.google.android.glass.widget.Slider.Determinate)

Example 94 with Animator

use of android.animation.Animator in project iosched by google.

the class SearchActivity method doEnterAnim.

/**
     * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
     * the search panel.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation – making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L).setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)).start();
    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                final ViewGroup searchPanelParent = (ViewGroup) searchPanel.getParent();
                final int revealRadius = (int) Math.hypot(searchPanelParent.getWidth(), searchPanelParent.getHeight());
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(), searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(250L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}
Also used : Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ViewTreeObserver(android.view.ViewTreeObserver) TargetApi(android.annotation.TargetApi)

Example 95 with Animator

use of android.animation.Animator in project iosched by google.

the class SearchActivity method doExitAnim.

/**
     * On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the
     * search panel.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doExitAnim() {
    final View searchPanel = findViewById(R.id.search_panel);
    // Center the animation on the top right of the panel i.e. near to the search button which
    // launched this screen. The starting radius therefore is the diagonal distance from the top
    // right to the bottom left
    final int revealRadius = (int) Math.hypot(searchPanel.getWidth(), searchPanel.getHeight());
    // Animating the radius to 0 produces the contracting effect
    Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(), searchPanel.getTop(), revealRadius, 0f);
    shrink.setDuration(200L);
    shrink.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
    shrink.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            searchPanel.setVisibility(View.INVISIBLE);
            ActivityCompat.finishAfterTransition(SearchActivity.this);
        }
    });
    shrink.start();
    // We also animate out the translucent background at the same time.
    findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)).start();
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) TargetApi(android.annotation.TargetApi)

Aggregations

Animator (android.animation.Animator)1413 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)868 ObjectAnimator (android.animation.ObjectAnimator)724 ValueAnimator (android.animation.ValueAnimator)630 AnimatorSet (android.animation.AnimatorSet)285 View (android.view.View)230 ViewGroup (android.view.ViewGroup)110 ArrayList (java.util.ArrayList)104 PropertyValuesHolder (android.animation.PropertyValuesHolder)96 Paint (android.graphics.Paint)79 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)75 ImageView (android.widget.ImageView)68 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)67 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)65 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)64 TextView (android.widget.TextView)61 RenderNodeAnimator (android.view.RenderNodeAnimator)51 ViewPropertyAnimator (android.view.ViewPropertyAnimator)51 Rect (android.graphics.Rect)50 Interpolator (android.view.animation.Interpolator)49