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:br.liveo.searchliveo.SearchLiveo.java

private SearchLiveo hideAnimation() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        if (getStatusBarHideColor() != -1) {
            mContext.getWindow().setStatusBarColor(getStatusBarHideColor());
        } else {//from  w  w  w .  j  av  a  2 s.  c  om
            mContext.getWindow().setStatusBarColor(getColorPrimaryDark());
        }

        final Animator animatorHide = ViewAnimationUtils.createCircularReveal(mViewSearch,
                mViewSearch.getWidth() - (int) dpToPixel(24, mContext), (int) dpToPixel(23, mContext),
                (float) Math.hypot(mViewSearch.getWidth(), mViewSearch.getHeight()), 0);
        animatorHide.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

                mContext.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                                .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mViewSearch.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorHide.setDuration(200);
        animatorHide.start();

    } else {

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
            }
        });

        Animation mFadeOut = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_out);
        mViewSearch.setAnimation(mFadeOut);
        mViewSearch.setVisibility(View.INVISIBLE);
    }

    mEdtSearch.setText("");
    mViewSearch.setEnabled(false);
    return this;
}

From source file:com.brandao.tictactoe.board.BoardFragment.java

public void animateSingleSquare(int inAnim, int outAnim, final int index) {
    final Animation shrink = AnimationUtils.loadAnimation(getActivity(), outAnim);
    shrink.setStartOffset(325);/*from w w w . j  ava 2 s . c  o m*/
    shrink.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
        }
    });

    Animation grow = AnimationUtils.loadAnimation(getActivity(), inAnim);
    grow.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            mScreens[index].startAnimation(shrink);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
        }
    });

    mScreens[index].startAnimation(grow);
}

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

private SearchCardLiveo hideAnimation() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        if (getStatusBarHideColor() != -1) {
            mContext.getWindow().setStatusBarColor(getStatusBarHideColor());
        } else {//from  w w w.  j a va  2 s .co m
            mContext.getWindow().setStatusBarColor(getColorPrimaryDark());
        }

        final Animator animatorHide = ViewAnimationUtils.createCircularReveal(mCardSearch,
                mCardSearch.getWidth() - (int) dpToPixel(24, mContext), (int) dpToPixel(23, mContext),
                (float) Math.hypot(mCardSearch.getWidth(), mCardSearch.getHeight()), 0);
        animatorHide.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

                mContext.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                                .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mCardSearch.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorHide.setDuration(200);
        animatorHide.start();

    } else {

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
            }
        });

        Animation mFadeOut = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_out);
        mCardSearch.setAnimation(mFadeOut);
        mCardSearch.setVisibility(View.INVISIBLE);
    }

    mEdtSearch.setText("");
    mCardSearch.setEnabled(false);
    return this;
}

From source file:com.nadmm.airports.ActivityBase.java

protected void setContentShown(View view, boolean shown, boolean animation) {
    View progress = view.findViewById(R.id.INTERNAL_PROGRESS_CONTAINER_ID);
    View content = view.findViewById(R.id.INTERNAL_FRAGMENT_CONTAINER_ID);

    if (progress == null || content == null) {
        return;/* w w w.ja v a2s  .c o m*/
    }

    if (shown) {
        if (animation) {
            progress.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
            content.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
        }
        progress.setVisibility(View.GONE);
        content.setVisibility(View.VISIBLE);
    } else {
        if (animation) {
            progress.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
            content.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
        }
        progress.setVisibility(View.VISIBLE);
        content.setVisibility(View.GONE);
    }
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

public Animation fadeInAnimation() {
    Animation fadeInAnimation = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
    fadeInAnimation.setStartOffset(200);
    fadeInAnimation.setDuration(300);//from ww w  .j a v a 2s  .  c o  m
    return fadeInAnimation;
}

From source file:com.gelakinetic.selfr.CameraActivity.java

/**
 * Hide the system bar & toolbar/* w  w  w .  j  a  va2  s .com*/
 */
private void hideControls() {
    /* Mark the views as animating */
    mControlsVisible = ViewState.IN_TRANSITION;
    mSystemBarVisible = ViewState.IN_TRANSITION;

    /* Hide UI first */
    Animation flyInAnimation = AnimationUtils.loadAnimation(this, R.anim.animation_fly_out);
    flyInAnimation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            /* Unused */
        }

        /**
         * When the animation completes, hide the controls view
         * @param animation The animation which reached its end.
         */
        @Override
        public void onAnimationEnd(Animation animation) {
            mControlsView.setVisibility(View.GONE);
            mControlsVisible = ViewState.GONE;
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            /* Unused */
        }
    });
    mControlsView.startAnimation(flyInAnimation);

    /* Schedule a runnable to remove the status and navigation bar after a delay */
    mHandler.removeCallbacks(mShowControlsRunnable);
    mHandler.removeCallbacks(mHideSystemBarRunnable);
    mHandler.removeCallbacks(mHideAllRunnable);
    mHandler.postDelayed(mHideSystemBarRunnable, UI_ANIMATION_DELAY);
}

From source file:com.github.topbottomsnackbar.TBSnackbar.java

private void out2(final int event, int animId) {
    Animation anim = AnimationUtils.loadAnimation(mView.getContext(), animId);
    anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    anim.setDuration(ANIMATION_DURATION);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override/*w  ww. jav  a2 s  . c om*/
        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.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

public Animation fadeOutAnimation() {
    Animation fadeOutAnimation = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
    fadeOutAnimation.setDuration(200);/* www .  j  a v  a2 s  . co m*/
    return fadeOutAnimation;
}

From source file:com.github.yggie.pulltorefresh.PullListFragment.java

/**
 * Set the list to be shown//from w w w .  ja v a 2  s  .c o  m
 *
 * @param shown If true, the list will be shown
 * @param animate If true, the change will be animated using a simple fade animation
 */

public void setListShown(boolean shown, boolean animate) {
    if (listShown == shown) {
        return;
    }
    listShown = shown;
    if (shown) {
        if (animate) {
            listView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            emptyView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        } else {
            listView.clearAnimation();
            emptyView.clearAnimation();
        }
        emptyView.setVisibility(View.GONE);
        listView.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            listView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            emptyView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        }
        emptyView.setVisibility(View.VISIBLE);
        listView.setVisibility(View.GONE);
    }
}

From source file:com.brandao.tictactoe.board.BoardFragment.java

public void panelInAnimate(ImageView i, final int symble) {
    boolean animate = mPrefs.getBoolean(Settings.PREF_ANIMATE, Settings.PREF_ANIMATE_DEFAULT);

    if (!animate) {
        finishMove(symble);//from  w w  w . ja  v  a2 s .  co m
        return;
    }

    Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_in);
    anim.setInterpolator(AnimationUtils.loadInterpolator(getActivity(), android.R.anim.overshoot_interpolator));
    anim.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            finishMove(symble);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
        }
    });

    i.startAnimation(anim);
}