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.emmasuzuki.quickreturnlistview.view.QuickReturnListView.java

private void animateQuickReturnViewToDest(final int destY) {
    // Pre-honeycomb style
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
            Animation.ABSOLUTE, 0, Animation.ABSOLUTE, destY - mQuickReturnView.getTop());
    animation.setFillEnabled(true);/* w w  w. j  av a  2s . com*/
    animation.setDuration(mSettleAnimationDuration);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // Noop
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // TranslateAnimation does not change view's position, so
            // after the animation end, manually set quick return view position to destination
            setQuickReturnViewY(destY);
        }

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

    mQuickReturnView.startAnimation(animation);
}

From source file:com.javierarboleda.visualtilestogether.activities.SignInActivity.java

private void animateSignInButton(float fromAlpha, float toAlpha, final boolean invisible) {

    final View googleIconImageView = findViewById(R.id.ivGoogleIcon);
    final View signInTextView = findViewById(R.id.tvSignIn);
    final View buttonOutlineView = findViewById(R.id.viewButtonOutline);

    Animation animation = new AlphaAnimation(fromAlpha, toAlpha);
    if (invisible) {
        animation.setDuration(300);//from w  ww  .j  a  va  2 s.c  om
        mSignInButton.setIndeterminateProgressMode(true);
        mSignInButton.setProgress(50);
        mSignInButton.setClickable(false);
    } else {
        animation.setDuration(900);
        mSignInButton.setProgress(0);
        mSignInButton.setClickable(true);
    }

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

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (invisible) {
                googleIconImageView.setVisibility(View.INVISIBLE);
                signInTextView.setVisibility(View.INVISIBLE);
                buttonOutlineView.setVisibility(View.INVISIBLE);
            } else {
                googleIconImageView.setVisibility(View.VISIBLE);
                signInTextView.setVisibility(View.VISIBLE);
                buttonOutlineView.setVisibility(View.VISIBLE);
            }

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    googleIconImageView.startAnimation(animation);
    signInTextView.startAnimation(animation);
    buttonOutlineView.startAnimation(animation);
}

From source file:com.jins_meme.bridge.CameraMenuFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation anim = super.onCreateAnimation(transit, enter, nextAnim);
    if (anim == null) {
        if (enter) {
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.config_in);
        } else {//from  w  ww  .  j av a2  s  .  c  om
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.config_out);
        }
    }
    if (enter && anim != null) {
        anim.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (checkIfAllRequiedPermissionGranted()) {
                    mCamera.reopenCamera();
                } else {
                    isPermissionRequested = true;
                    requestPermissions(getPermissionsNotGrantedYet(),
                            getResources().getInteger(R.integer.PERMISSION_REQUEST_CODE_CAMERA));
                }
            }
        });
    }
    return anim;
}

From source file:com.codefororlando.transport.MapsActivity.java

private void removeSelectableItemFragment() {
    final Fragment selectableItemFragment = getFragmentManager().findFragmentByTag(ISelectableItemFragment.TAG);
    if (selectableItemFragment != null) {
        final View view = selectableItemFragment.getView();
        if (view == null) {
            return;
        }// w  w w . j a  v  a  2  s  . co m

        final int animationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);

        {
            final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight());
            animation.setDuration(animationDuration);
            animation.setInterpolator(new AccelerateDecelerateInterpolator());
            filterView.startAnimation(animation);
        }
        {
            final FragmentManager fragmentManager = getFragmentManager();
            final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight());
            animation.setDuration(animationDuration);
            animation.setAnimationListener(new EmptyAnimationListener() {
                @Override
                public void onAnimationEnd(Animation animation) {
                    try {
                        fragmentManager.beginTransaction().remove(selectableItemFragment)
                                .commitAllowingStateLoss();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            view.startAnimation(animation);
        }
    }
}

From source file:org.nla.tarotdroid.lib.ui.GameReadFragment.java

/**
 * Displays game index in game set and then smoothly removes the text.
 *//*from   w w w. j  av a  2  s  .  c  o m*/
private void smoothlyHideText() {
    final TextView onTop = (TextView) this.frameLayout.findViewById(R.id.txtOnTop);
    onTop.setText(this.game.getIndex() + "/" + this.game.getHighestGameIndex());

    Animation animation1 = new AlphaAnimation(1.0f, 0.0f);
    animation1.setDuration(1500);

    //animation1 AnimationListener
    animation1.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation arg0) {
            // start animation2 when animation1 ends (continue)
            onTop.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
        }

        @Override
        public void onAnimationStart(Animation arg0) {
        }
    });

    onTop.startAnimation(animation1);
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

private void setBarUpAnimation(View viewToAnimate) {
    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_out_up);
    animation.setAnimationListener(new SlideUpAnimationListener(getSupportActionBar()));
    viewToAnimate.startAnimation(animation);
}

From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java

private void hideAddPlaceButtons() {
    Animation slideDown = AnimationUtils.loadAnimation(this.getActivity().getApplicationContext(),
            R.anim.add_place_buttons_hide);
    slideDown.setAnimationListener(new Animation.AnimationListener() {
        @Override/*from   w w w  .ja v  a2s  .  com*/
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            getView().findViewById(R.id.add_place_overlay).setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    getView().findViewById(R.id.add_place_buttons).startAnimation(slideDown);
}

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

/**
 * Manually hides the stream status bar from view.
 *//*  w  ww .ja v  a 2  s.  co  m*/
public void hideStatusBar() {
    Log.v(TAG, "Manually hiding status bar.");
    final LinearLayout statusContainer = (LinearLayout) getActivity()
            .findViewById(R.id.stream_status_container_linearlayout);
    final Animation animOut = AnimationUtils.loadAnimation(getActivity(), 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.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public void openMenu() {
    //?//from  w  w  w  .  ja  v  a  2  s.  c  o  m
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.menu_show_action);
    mMenu.clearAnimation();
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            mMenu.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

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

From source file:tv.acfun.a63.CommentsActivity.java

void showBar() {
    if (isBarShowing)
        return;//from   ww w  .ja v a2s  . c om
    isBarShowing = true;
    getSupportActionBar().show();
    if (mAnim != null)
        mAnim.cancel();
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in);
    anim.setAnimationListener(mShowListener);
    mAnim = anim;
    mCommentBar.startAnimation(mAnim);
}