Example usage for android.animation Animator start

List of usage examples for android.animation Animator start

Introduction

In this page you can find the example usage for android.animation Animator start.

Prototype

public void start() 

Source Link

Document

Starts this animation.

Usage

From source file:me.sweetll.tucao.widget.PasswordEntry.java

private void passwordVisibilityToggled(boolean isMasked, CharSequence password) {
    if (maskDrawable == null) {
        // lazily create the drawable that morphs the dots
        if (!ViewCompat.isLaidOut(this) || getText().length() < 1)
            return;
        maskDrawable = new MaskMorphDrawable(getContext(), getPaint(), getBaseline(),
                getLayout().getPrimaryHorizontal(1), getTextLeft());
        maskDrawable.setBounds(getPaddingLeft(), getPaddingTop(), getPaddingLeft(),
                getHeight() - getPaddingBottom());
        getOverlay().add(maskDrawable);/*from www. j  ava 2s.com*/
    }

    // hide the text during the animation
    setTextColor(Color.TRANSPARENT);
    Animator maskMorph = isMasked ? maskDrawable.createShowMaskAnimator(password)
            : maskDrawable.createHideMaskAnimator(password);
    maskMorph.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setTextColor(textColor); // restore the proper text color
        }
    });
    maskMorph.start();
}

From source file:org.chromium.chrome.browser.physicalweb.ListUrlsActivity.java

private void hideBottomBar() {
    Animator animator = createTranslationYAnimator(mBottomBar, mBottomBar.getHeight(), DURATION_SLIDE_DOWN_MS);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/* www .  ja va2s .co  m*/
        public void onAnimationEnd(Animator animation) {
            mBottomBar.setVisibility(View.GONE);
        }
    });
    animator.start();
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel./*from ww  w  . j  a  v  a2  s .c o  m*/
 */
@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
                int revealRadius = ((ViewGroup) searchPanel.getParent()).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;
            }
        });
    }
}

From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel.//from  ww  w.j  av  a2s .  com
 *
 * Support CircularReveal :
 * https://github.com/ozodrukh/CircularReveal
 */
@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
                int revealRadius = ((ViewGroup) searchPanel.getParent()).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(350L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:com.example.jonas.materialmockups.activities.ExhibitDetailsActivity.java

/**
 * Shows the audio toolbar./*w  w w .  j  a  va2s.c  om*/
 * @return true if the toolbar has been revealed, false otherwise.
 */
private boolean showAudioToolbar() {
    // check only if mRevealView != null. If isAudioToolbarHidden == true is also checked,
    // the toolbar cannot be displayed on savedInstanceState
    if (mRevealView != null) {
        int cx = (mRevealView.getLeft() + mRevealView.getRight());
        int cy = mRevealView.getTop();
        int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight());

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

            SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(800);

            mRevealView.setVisibility(View.VISIBLE);
            animator.start();

        } else {
            Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0,
                    radius);
            mRevealView.setVisibility(View.VISIBLE);
            anim.start();
        }

        isAudioToolbarHidden = false;
        return true;
    }

    return false;
}

From source file:org.ciasaboark.tacere.activity.AboutActivity.java

@TargetApi(21)
private void toggleVisibilityCircularReveal(final View view) {
    if (view.getVisibility() == View.VISIBLE) {
        //the view is visible, so animate it out then set visibility to GONE
        int cx;// w  w w.jav a 2  s . c  om
        int cy;
        if (this.x == null || this.y == null) {
            // get the center for the clipping circle
            cx = (view.getLeft() + view.getRight()) / 2;
            cy = (view.getTop() + view.getBottom()) / 2;
        } else {
            //a touch event has been recorded, use the last known coordinates
            cx = this.x;
            cy = this.y;
        }

        // get the initial radius for the clipping circle
        int initialRadius = view.getWidth();

        // create the animation (the final radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(View.INVISIBLE);
            }
        });
        anim.setDuration(700);
        // start the animation
        anim.start();
    } else {
        //the view is not visible (either GONE or INVISIBILE), set visibility to VISIBLE, then
        //animate in
        int cx;
        int cy;
        if (this.x == null || this.y == null) {
            // get the center for the clipping circle
            cx = (view.getLeft() + view.getRight()) / 2;
            cy = (view.getTop() + view.getBottom()) / 2;
        } else {
            //a touch event has been recorded, use the last known coordinates
            cx = this.x;
            cy = this.y;
        }

        // get the final radius for the clipping circle
        int finalRadius = view.getWidth();

        // create and start the animator for this view
        // (the start radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
        anim.setDuration(500);
        view.setVisibility(View.VISIBLE);
        anim.start();
    }
}

From source file:com.hadis.mylunbo.carrousel.CircleIndicator.java

private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) {
        animator.end();//from  www.j a v a2 s .  com
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}

From source file:com.ruesga.rview.fragments.RevealDialogFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void performEnterRevealTransition() {
    if (!mDoReveal || getDialog() == null || getDialog().getWindow() == null) {
        mDoReveal = false;//www  .j a  v a2  s. c  o m
        return;
    }

    final View v = getDialog().getWindow().getDecorView();
    if (!v.isAttachedToWindow()) {
        mDoReveal = false;
        return;
    }
    v.setVisibility(View.VISIBLE);
    Rect dialogRect = computeViewOnScreen(v);

    int cx = v.getMeasuredWidth() / 2;
    int cy = v.getMeasuredHeight() / 2;
    if (mAnchorRect != null) {
        cx = Math.min(Math.max(mAnchorRect.centerX(), dialogRect.left), dialogRect.right) - dialogRect.left;
        cy = Math.min(Math.max(mAnchorRect.centerY(), dialogRect.top), dialogRect.bottom) - dialogRect.top;
    }

    int finalRadius = Math.max(v.getWidth(), v.getHeight());
    Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius);
    anim.setDuration(350);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            onDialogReveled();
            mDoReveal = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    anim.start();
}

From source file:io.github.silencio_app.silencio.MainActivity.java

public void showGraph(View view) {
    View myView = findViewById(R.id.graph);

    // get the center for the clipping circle
    int cx = myView.getWidth() / 2;
    int cy = myView.getHeight() / 2;

    // get the final radius for the clipping circle
    float finalRadius = (float) Math.hypot(cx, cy);

    // create the animator for this view (the start radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);

    // make the graph and meter visible and start the animation
    myView.setVisibility(View.VISIBLE);
    //        db_meter.setVisibility(View.VISIBLE);
    anim.start();
}

From source file:shetye.prathamesh.notifyme.Utilities.java

public void hideView(final LinearLayout lview) {
    // get the center for the clipping circle
    int cx = (lview.getLeft() + lview.getRight()) / 2;
    int cy = (lview.getTop() + lview.getBottom()) / 2;
    // get the initial radius for the clipping circle
    int initialRadius = lview.getWidth();
    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(lview, cx, cy, initialRadius, 0);
    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override//  w w  w.ja v  a 2  s . com
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            lview.setVisibility(View.INVISIBLE);
        }
    });
    anim.start();
}