Example usage for android.view.animation Animation setAnimationListener

List of usage examples for android.view.animation Animation setAnimationListener

Introduction

In this page you can find the example usage for android.view.animation Animation setAnimationListener.

Prototype

public void setAnimationListener(AnimationListener listener) 

Source Link

Document

Binds an animation listener to this animation.

Usage

From source file:com.dvn.vindecoder.ui.seller.AddVehicalAndPayment.java

private void setScrollContent() {

    final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(
            R.id.collapsing_toolbar);/*from   www  .jav  a2s  . co  m*/
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout);
    final RelativeLayout img_container1 = (RelativeLayout) findViewById(R.id.img_container1);
    // load the animation
    final Animation animFadein = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fadein);
    // start the animation
    // set animation listener
    animFadein.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            /* if(img_container1.getVisibility() == View.VISIBLE)
             {
                 img_container1.setVisibility(View.GONE);
             }*/
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        boolean isShow = false;
        int scrollRange = -1;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (scrollRange == -1) {
                scrollRange = appBarLayout.getTotalScrollRange();
                // Log.e("val","-1  choti imge ko hide kerna h");
                img_container1.setVisibility(View.GONE);
            }
            if (scrollRange + verticalOffset == 0) {
                //  collapsingToolbarLayout.setTitle("Title");
                // Log.e("val","0 choti imge ko show kerna h");
                img_container1.setVisibility(View.VISIBLE);
                img_container1.startAnimation(animFadein);
                isShow = true;
            } else if (isShow) {
                // collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work
                //Log.e("val","Showing choti imge ko hide kerna h");
                img_container1.setVisibility(View.GONE);

                isShow = false;
            }
        }
    });
}

From source file:com.dvn.vindecoder.ui.seller.GetAllVehicalSellerDetails.java

private void setScrollContent() {

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout);
    final RelativeLayout img_container1 = (RelativeLayout) findViewById(R.id.img_container1);
    // load the animation
    final Animation animFadein = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fadein);
    // start the animation
    // set animation listener
    animFadein.setAnimationListener(new Animation.AnimationListener() {
        @Override/*  w  ww . java  2s.  c  om*/
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            /* if(img_container1.getVisibility() == View.VISIBLE)
             {
                 img_container1.setVisibility(View.GONE);
             }*/
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        boolean isShow = false;
        int scrollRange = -1;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (scrollRange == -1) {
                scrollRange = appBarLayout.getTotalScrollRange();
                // Log.e("val","-1  choti imge ko hide kerna h");
                img_container1.setVisibility(View.GONE);
            }
            if (scrollRange + verticalOffset == 0) {
                //  collapsingToolbarLayout.setTitle("Title");
                // Log.e("val","0 choti imge ko show kerna h");
                img_container1.setVisibility(View.VISIBLE);
                img_container1.startAnimation(animFadein);
                isShow = true;
            } else if (isShow) {
                // collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work
                //Log.e("val","Showing choti imge ko hide kerna h");
                img_container1.setVisibility(View.GONE);

                isShow = false;
            }
        }
    });
}

From source file:com.commonsware.cwac.crossport.design.widget.BaseTransientBottomBar.java

private void animateViewOut(final int event) {
    if (Build.VERSION.SDK_INT >= 12) {
        final ValueAnimator animator = new ValueAnimator();
        animator.setIntValues(0, mView.getHeight());
        animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        animator.setDuration(ANIMATION_DURATION);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override/*from w w  w. j a va 2  s .c om*/
            public void onAnimationStart(Animator animator) {
                mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                onViewHidden(event);
            }
        });
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            private int mPreviousAnimatedIntValue = 0;

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                int currentAnimatedIntValue = (int) animator.getAnimatedValue();
                if (USE_OFFSET_API) {
                    ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - mPreviousAnimatedIntValue);
                } else {
                    mView.setTranslationY(currentAnimatedIntValue);
                }
                mPreviousAnimatedIntValue = currentAnimatedIntValue;
            }
        });
        animator.start();
    } else {
        final Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out);
        anim.setInterpolator(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.commonsware.cwac.crossport.design.widget.BaseTransientBottomBar.java

void animateViewIn() {
    if (Build.VERSION.SDK_INT >= 12) {
        final int viewHeight = mView.getHeight();
        if (USE_OFFSET_API) {
            ViewCompat.offsetTopAndBottom(mView, viewHeight);
        } else {// w  ww.jav  a 2 s  . c om
            mView.setTranslationY(viewHeight);
        }
        final ValueAnimator animator = new ValueAnimator();
        animator.setIntValues(viewHeight, 0);
        animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        animator.setDuration(ANIMATION_DURATION);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animator) {
                mContentViewCallback.animateContentIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION,
                        ANIMATION_FADE_DURATION);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                onViewShown();
            }
        });
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            private int mPreviousAnimatedIntValue = viewHeight;

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                int currentAnimatedIntValue = (int) animator.getAnimatedValue();
                if (USE_OFFSET_API) {
                    ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - mPreviousAnimatedIntValue);
                } else {
                    mView.setTranslationY(currentAnimatedIntValue);
                }
                mPreviousAnimatedIntValue = currentAnimatedIntValue;
            }
        });
        animator.start();
    } else {
        final Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in);
        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.brandao.tictactoe.board.BoardFragment.java

public void finishMove(int symble) {
    boolean animate = mPrefs.getBoolean(Settings.PREF_ANIMATE, true);
    int[] winSpots = checkForWin(symble);
    final int tempSymble = symble;

    if (winSpots != null) {
        Animation animOut = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
        animOut.setAnimationListener(new AnimationListener() {
            @Override//  w ww  .j a va  2 s.  c  o m
            public void onAnimationStart(Animation animation) {
                mAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mAnimating = false;

                setWinner(tempSymble);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

        });

        if (animate) {
            for (int winSpot : winSpots) {
                mScreens[winSpot].startAnimation(animOut);
            }
        } else {
            setWinner(tempSymble);
        }
    } else {
        if (checkForTie()) {
            setWinner(C.SYMBLE_NULL);
        } else {
            switch (mGameState) {
            case C.STATE_PLAYER_ONE_TURN: {
                symble = C.SYMBLE_PLAYER_TWO;

                break;
            }
            case C.STATE_PLAYER_TWO_TURN: {
                symble = C.SYMBLE_PLAYER_ONE;

                break;
            }
            }

            mMenuItemReplay.setEnabled(true);
            mMenuItemHint.setEnabled(true);

            nextTurn(symble);
        }
    }
}

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

public void animateHintSquare(final int index) {
    final Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
    fadeOut.setAnimationListener(new AnimationListener() {
        @Override/*w  w w  .  ja  v  a  2  s .  com*/
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            mScreens[index].setBackgroundResource(R.drawable.transparent_image);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

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

    Animation fadeIn = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
    fadeIn.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            mScreens[index].startAnimation(fadeOut);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
            if (mGameState == C.STATE_PLAYER_ONE_TURN) {
                mScreens[index].setBackgroundResource(R.drawable.ic_green_x_android);
            } else {
                if (mGameState == C.STATE_PLAYER_TWO_TURN) {
                    mScreens[index].setBackgroundResource(R.drawable.ic_red_o_android);
                }
            }
        }
    });

    mScreens[index].startAnimation(fadeIn);
}

From source file:tk.eatheat.omnisnitch.ui.SwitchLayout.java

private Animation getShowFavoriteAnimation() {
    int animId = R.anim.slide_down;
    Animation animation = AnimationUtils.loadAnimation(mContext, animId);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override//from ww w.  j a v  a  2s  .  c  om
        public void onAnimationEnd(Animation animation) {
            setButtonGlow(mOpenFavorite, mShowFavorites ? "arrow_up" : "arrow_down",
                    mShowFavorites ? R.drawable.arrow_up : R.drawable.arrow_down, false);
        }

        @Override
        public void onAnimationStart(Animation animation) {
            mFavoriteListHorizontal.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    return animation;
}

From source file:tk.eatheat.omnisnitch.ui.SwitchLayout.java

private Animation getHideFavoriteAnimation() {
    int animId = R.anim.slide_up;
    Animation animation = AnimationUtils.loadAnimation(mContext, animId);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override//from   w  w w. j  a v  a2 s  .  c o m
        public void onAnimationEnd(Animation animation) {
            setButtonGlow(mOpenFavorite, mShowFavorites ? "arrow_up" : "arrow_down",
                    mShowFavorites ? R.drawable.arrow_up : R.drawable.arrow_down, false);

            mFavoriteListHorizontal.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    return animation;
}

From source file:tk.eatheat.omnisnitch.ui.SwitchLayout.java

private Animation getShowAnimation() {
    int animId = R.anim.slide_right_in;

    if (mConfiguration.mLocation == 1) {
        animId = R.anim.slide_left_in;//from   w w  w .j a  va2 s.com
    }
    Animation animation = AnimationUtils.loadAnimation(mContext, animId);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            showDone();
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    return animation;
}

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);// w w  w .  j  a  v a  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);
}