Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadAnimation.

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:android.support.designox.widget.Snackbar.java

private void animateViewIn() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.setTranslationY(mView, mView.getHeight());
        ViewCompat.animate(mView).translationY(0f).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override/* ww w  .j  a v  a2  s . c o  m*/
                    public void onAnimationStart(View view) {
                        if (!mAccessibilityManager.isEnabled()) {
                            // Animating the children in causes Talkback to think that they're
                            // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired.
                            // Fixed by skipping the animation when an accessibility manager
                            // is enabled
                            mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION,
                                    ANIMATION_FADE_DURATION);
                        }
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewShown();
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in_ox);
        anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                onViewShown();
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:com.lcl.designsnackbar.tsnackbar.TSnackbar.java

void animateViewIn() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.setTranslationY(mView, -mView.getHeight());
        ViewCompat.animate(mView).translationY(0f).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override/*from   ww w .  j a  v a  2 s .  co  m*/
                    public void onAnimationStart(View view) {
                        mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION,
                                ANIMATION_FADE_DURATION);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        if (mCallback != null) {
                            mCallback.onShown(TSnackbar.this);
                        }
                        SnackbarManager.getInstance().onShown(mManagerCallback);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(mView.getContext(),
                com.lcl.designsnackbar.R.anim.design_tsnackbar_in);
        anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                if (mCallback != null) {
                    mCallback.onShown(TSnackbar.this);
                }
                SnackbarManager.getInstance().onShown(mManagerCallback);
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:com.jet.sweettips.snackbar.SweetSnackbar.java

private void animateViewOut(final int event) {
    Animation anim = null;/*from w w  w .  j  av  a 2  s.c  o  m*/
    if (animateOut != -1) {
        anim = AnimationUtils.loadAnimation(mView.getContext(), animateOut);
    } else {
        anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out);
    }
    anim.setInterpolator(com.jet.sweettips.util.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    anim.setDuration(ANIMATION_DURATION);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            onViewHidden(event);
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mView.startAnimation(anim);
}

From source file:com.heightechllc.breakify.MainActivity.java

/**
 * Sets the UI for the "paused" state//  ww w. j  a v a  2s  .  c o  m
 */
private void setUIForPausedState() {
    // Update the start / stop label
    startStopLbl.setText(R.string.resume);
    startStopLbl.setVisibility(View.VISIBLE);

    // Blink the time and state labels while paused
    Animation blinkAnim = AnimationUtils.loadAnimation(this, R.anim.blink);
    timeLbl.startAnimation(blinkAnim);
    stateLbl.startAnimation(blinkAnim);
}

From source file:com.battlelancer.seriesguide.ui.ShowsActivity.java

/**
 * Shows or hides a custom indeterminate progress indicator inside this activity layout.
 *//*from  w  ww  . j av  a  2 s.c om*/
public void setProgressVisibility(boolean isVisible) {
    if (mProgressBar.getVisibility() == (isVisible ? View.VISIBLE : View.GONE)) {
        // already in desired state, avoid replaying animation
        return;
    }
    mProgressBar.startAnimation(AnimationUtils.loadAnimation(mProgressBar.getContext(),
            isVisible ? R.anim.fade_in : R.anim.fade_out));
    mProgressBar.setVisibility(isVisible ? View.VISIBLE : View.GONE);
}

From source file:br.liveo.searchliveo.SearchLiveo.java

/**
 * Show SearchLiveo//from  w w  w  .j  a  v a  2s  .  c  o m
 */
public SearchLiveo show() {
    setActive(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        try {
            showAnimation();
        } catch (ClassCastException e) {
            throw new ClassCastException(mContext.getString(R.string.warning_with));
        }

    } else {

        Animation mFadeIn = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_in);
        mViewSearch.setEnabled(true);
        mViewSearch.setVisibility(View.VISIBLE);
        mViewSearch.setAnimation(mFadeIn);

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            }
        });
    }

    mEdtSearch.requestFocus();
    return this;
}

From source file:com.ingenia.fasttrack.SnackBar.MultilineSnackbar.java

private void animateViewOut(final int event) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.animate(mView).translationY(mView.getHeight())
                .setInterpolator(com.ingenia.fasttrack.SnackBar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    boolean mEndCalled = false;

                    @Override//  ww  w . ja  va2s.com
                    public void onAnimationStart(View view) {
                        if (!mAccessibilityManager.isEnabled()) {
                            // Animating the children in causes Talkback to think that they're
                            // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired.
                            // Fixed by skipping the animation when an accessibility manager
                            // is enabled
                            mView.animateChildrenOut(0, ANIMATION_FADE_DURATION);
                        }
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewHidden(event);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(mView.getContext(),
                android.support.design.R.anim.design_snackbar_out);
        anim.setInterpolator(com.ingenia.fasttrack.SnackBar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                onViewHidden(event);
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:com.iw.flirten.snackbar.Snackbar.MultilineSnackbar.java

private void animateViewOut(final int event) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.animate(mView).translationY(mView.getHeight())
                .setInterpolator(com.iw.flirten.snackbar.Snackbar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    boolean mEndCalled = false;

                    @Override/*w ww  .  j a v  a  2s.  c o m*/
                    public void onAnimationStart(View view) {
                        if (!mAccessibilityManager.isEnabled()) {
                            // Animating the children in causes Talkback to think that they're
                            // not visible when the TYPE_WINDOW_CONTENT_CHANGED event if fired.
                            // Fixed by skipping the animation when an accessibility manager
                            // is enabled
                            mView.animateChildrenOut(0, ANIMATION_FADE_DURATION);
                        }
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewHidden(event);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(mView.getContext(),
                android.support.design.R.anim.design_snackbar_out);
        anim.setInterpolator(com.iw.flirten.snackbar.Snackbar.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                onViewHidden(event);
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:com.rowland.movies.ui.fragments.DetailFragment.java

@OnClick(R.id.favorite_fab)
public void onToggleFavouriteMovie() {
    // The response Animation
    Animation simpleRotateAnimation;//from   w ww.  java2  s .  c o m
    if (!isFavourite) {
        // Set movie isFavourite to true
        mMovie.setIsFavourite(true);
        isFavourite = true;
        // Create an Animation
        simpleRotateAnimation = AnimationUtils.loadAnimation(mFavoriteFab.getContext(),
                R.anim.rotate_clockwise);
    } else {
        // Set movie isFavourite to false
        mMovie.setIsFavourite(false);
        isFavourite = false;
        // Create an Animation
        simpleRotateAnimation = AnimationUtils.loadAnimation(mFavoriteFab.getContext(),
                R.anim.rotate_anticlockwise);
    }
    // Save changes made on movie
    mMovie.save();
    // Update the drawable
    updateFabDrawable();
    // Animate the Floating action button
    mFavoriteFab.startAnimation(simpleRotateAnimation);
}

From source file:br.liveo.searchliveo.SearchCardLiveo.java

/**
 * Show SearchCardLiveo//from   w ww .j  a  v a  2  s .  c o  m
 */
public SearchCardLiveo show() {
    setActive(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        try {
            showAnimation();
        } catch (ClassCastException e) {
            throw new ClassCastException(mContext.getString(R.string.warning_with));
        }

    } else {

        Animation mFadeIn = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_in);
        mCardSearch.setEnabled(true);
        mCardSearch.setVisibility(View.VISIBLE);
        mCardSearch.setAnimation(mFadeIn);

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            }
        });
    }

    mEdtSearch.requestFocus();
    return this;
}