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:tv.acfun.a63.CommentsActivity.java

void hideBar() {
    if (!isBarShowing)
        return;/*ww  w.j av a2  s . c om*/
    isBarShowing = false;
    getSupportActionBar().hide();
    if (mAnim != null)
        mAnim.cancel();
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out);
    anim.setAnimationListener(mHideListener);
    mAnim = anim;
    mCommentBar.startAnimation(mAnim);
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public void closeMenu() {
    ///*w w w .  j a va2 s .com*/
    Animation animation = AnimationUtils.loadAnimation(GalleryActivity.this, R.anim.menu_hide_action);
    mMenu.clearAnimation();
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mMenu.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mMenu.setAnimation(animation);
    animation.start();
    mIsMenuOpen = false;
}

From source file:com.kuloud.android.unity.ui.widget.steprefresh.PullToRefreshView.java

private void animateOffsetToPosition(Animation animation, boolean isEndAnimation) {
    mFrom = mCurrentOffsetTop;//from  w w w.  jav a2s. c o m
    mFromDragPercent = mCurrentDragPercent;
    long animationDuration = Math.abs((long) (!isEndAnimation ? MAX_OFFSET_ANIMATION_DURATION
            : MAX_OFFSET_END_ANIMATION_DURATION * mFromDragPercent));

    animation.reset();
    animation.setDuration(animationDuration);
    animation.setInterpolator(mDecelerateInterpolator);
    animation.setAnimationListener(mToStartListener);
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(animation);
}

From source file:com.sunho.nating.fragments.DetailPlaceFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation animation = AnimationUtils.loadAnimation(getActivity(),
            enter ? android.R.anim.fade_in : android.R.anim.fade_out);
    // We bind a listener for the fragment transaction. We only bind it when
    // this fragment is entering.
    if (animation != null && enter) {
        animation.setAnimationListener(this);
    }//www  .  ja  v  a  2  s.com
    return animation;
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public void onBackPressed() {
    //override/*ww w . ja v  a 2  s . c o  m*/
    if (mIsMenuOpen) {
        Animation animation = AnimationUtils.loadAnimation(GalleryActivity.this, R.anim.menu_hide_action);
        mMenu.clearAnimation();
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mMenu.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mMenu.setAnimation(animation);
        animation.start();
        mIsMenuOpen = false;
    } else {
        mComic.setReadChapter(mChapterPosition);
        mComic.setReadPage(mViewPager.getCurrentItem());
        Intent intent = new Intent();
        intent.putExtra("comic", mComic);
        setResult(0, intent);
        finish();
    }
}

From source file:fm.krui.kruifm.StreamActivity.java

/**
 * Manually hides the stream status bar from view.
 *//*from  w  w w  . jav  a 2s.  co m*/
public void hideStatusBar() {
    Log.v(TAG, "Manually hiding status bar.");
    final LinearLayout statusContainer = (LinearLayout) this
            .findViewById(R.id.stream_status_container_linearlayout);
    final Animation animOut = AnimationUtils.loadAnimation(this, R.anim.translate_down);
    animOut.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // Hide the container from view when it has finished animating
            statusContainer.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    statusContainer.startAnimation(animOut);

}

From source file:org.y20k.transistor.PlayerActivityFragment.java

private void changeVisualState(Context context) {
    // get rotate animation from xml
    Animation rotate;
    if (mPlayback) {
        // if playback has been started get start animation
        rotate = AnimationUtils.loadAnimation(context, R.anim.rotate_clockwise_slow);
    } else {/*from w  w  w  . j  av a2 s.com*/
        // if playback has been stopped get stop animation
        rotate = AnimationUtils.loadAnimation(context, R.anim.rotate_counterclockwise_fast);
    }

    // attach listener for animation end
    rotate.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // set up button symbol and playback indicator afterwards
            setVisualState();
        }

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

    // start animation of button
    mPlaybackButton.startAnimation(rotate);

}

From source file:com.spoiledmilk.ibikecph.map.MapActivity.java

private void translate(float deltaX, final boolean finalAnim) {

    if (leftMenu != null && leftMenu.getView() != null) {
        newX = posX + deltaX;//from  ww  w.java  2  s . co m
        if (slidden) {
            if (newX < -maxSlide)
                newX = -maxSlide;
            else if (newX > 0)
                newX = 0;
        } else {
            if (newX < 0)
                newX = 0;
            else if (newX > maxSlide)
                newX = maxSlide;
        }

        if (((int) newX) <= 0) {
            mapDisabledView.setVisibility(View.GONE);
        }

        final boolean newSlidden = slidden ? newX > -SLIDE_THRESHOLD : newX > SLIDE_THRESHOLD;

        if (finalAnim) {
            newX = (slidden == newSlidden) ? 0 : (slidden ? -maxSlide : maxSlide);
        }

        if (animation != null && animation.isInitialized()) {
            parentContainer.clearAnimation();
            animation.cancel();
            leftMenu.getView().invalidate();
        }

        LOG.d("translate animation from posX " + posX + " to " + newX);
        animation = new TranslateAnimation(posX, newX, 0, 0);
        animation.setDuration(finalAnim ? 100 : 0);

        animation.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (!finalAnim) {
                    animation.setFillEnabled(true);
                    animation.setFillAfter(true);
                } else {
                    parentContainer.clearAnimation();

                    if (slidden == newSlidden) {
                        if (!slidden) {
                            leftContainer.setVisibility(View.GONE);
                            mapDisabledView.setVisibility(View.GONE);
                            leftMenu.getView().invalidate();
                        } else {
                            mapDisabledView.setVisibility(View.VISIBLE);
                            leftMenu.getView().invalidate();
                        }
                        return;
                    }
                    slidden = newSlidden;

                    int leftmargin = slidden ? maxSlide : 0;
                    int rightMargin = slidden ? 0 : maxSlide;
                    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) parentContainer
                            .getLayoutParams();
                    lp.setMargins(leftmargin, lp.topMargin, rightMargin, lp.bottomMargin);
                    parentContainer.setLayoutParams(lp);
                    if (leftmargin == 0) {
                        leftContainer.setVisibility(View.GONE);
                        mapDisabledView.setVisibility(View.GONE);
                        leftMenu.getView().invalidate();
                    }

                    posX = 0;

                    Fragment fr = getSupportFragmentManager().findFragmentById(R.id.leftContainer);
                    if (fr != null && fr instanceof EditFavoriteFragment) {
                        ((EditFavoriteFragment) fr).hideKeyboard();
                    } else if (fr != null && fr instanceof AddFavoriteFragment) {
                        ((AddFavoriteFragment) fr).hideKeyboard();
                    }

                }
            }
        });

        posX = newX;

        parentContainer.startAnimation(animation);
    }
}

From source file:android.support.design.widget.BaseTransientBottomBar.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(FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override/*w  w  w.  j a  va 2  s  . c o  m*/
                    public void onAnimationStart(View view) {
                        mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewHidden(event);
                    }
                }).start();
    } else {
        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:android.support.design.widget.BaseTransientBottomBar.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   w  w w  .j  a  v  a 2s  .  co m
                    public void onAnimationStart(View view) {
                        mContentViewCallback.animateContentIn(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);
        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);
    }
}