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:org.gdg.frisbee.android.event.EventOverviewFragment.java

public void setIsLoading(boolean isLoading) {

    if (isLoading == mLoading || getActivity() == null)
        return;/*from w  w  w  .j a v  a 2s .  c  o  m*/

    mLoading = isLoading;

    if (isLoading) {
        mProgressContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        mProgressContainer.setVisibility(View.VISIBLE);
    } else {
        Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
        fadeOut.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (mProgressContainer != null)
                    mProgressContainer.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mProgressContainer.startAnimation(fadeOut);
    }
}

From source file:cn.lingox.android.share.view.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }/*  w w  w . j  av  a2 s  .co m*/

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:com.example.xyzreader.util.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {

        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//from ww  w  . j  a  v  a 2 s.  co  m

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:com.simon.dribbble.widget.navigationbar.behavior.BehaviorScrollZoomFab.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        BehaviorScrollZoomFab.this.mIsAnimatingOut = true;
                    }/*from   w w  w.  j  a  v  a 2 s  . c  om*/

                    public void onAnimationCancel(View view) {
                        BehaviorScrollZoomFab.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        BehaviorScrollZoomFab.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                BehaviorScrollZoomFab.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                BehaviorScrollZoomFab.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:com.geecko.QuickLyric.utils.ScreenSlidePagerAdapter.java

public void exitAction() {
    Animation slideOut = new TranslateAnimation(0f, -2000f, 0f, 0f);
    slideOut.setInterpolator(new AccelerateInterpolator());
    slideOut.setDuration(700);// w  ww.  j a  va2s . c o  m

    slideOut.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationEnd(Animation animation) {
            ((RelativeLayout) mPager.getParent()).setVisibility(View.GONE);
            ((MainActivity) mActivity).focusOnFragment = true;
            if (((MainActivity) mActivity).mDrawerToggle != null) {
                ((MainActivity) mActivity).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                ((MainActivity) mActivity).mDrawerToggle.setDrawerIndicatorEnabled(true);
            }
            mActivity.invalidateOptionsMenu();
            SharedPreferences.Editor editor = mActivity.getSharedPreferences("tutorial", Context.MODE_PRIVATE)
                    .edit();
            editor.putBoolean("seen", true);
            editor.apply();
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    ((MainActivity) mActivity).setStatusBarColor(null);
    ((MainActivity) mActivity).setNavBarColor(null);
    ((RelativeLayout) mPager.getParent()).startAnimation(slideOut);
}

From source file:com.hookedonplay.decoviewsample.SampleFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (getView() == null) {
        return;//w  w w. j av a 2  s. c  o m
    }

    mInitialized = true;
    final View replay = getView().findViewById(R.id.imageReplay);
    final View swipe = getView().findViewById(R.id.imageSwipe);
    if (replay != null) {
        replay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_hide);

                animation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        swipe.setVisibility(View.INVISIBLE);
                        replay.setEnabled(false);
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        setDemoFinished(false);
                        createAnimation();
                        replay.setEnabled(true);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });
                replay.startAnimation(animation);
            }
        });
    }
    createAnimation();
}

From source file:eu.power_switch.gui.animation.ScrollAwareFABBehavior.java

/**
 * Same animation that FloatingActionButton.Behavior uses to
 * hide the FAB when the AppBarLayout exits
 *
 * @param floatingActionButton FAB/*from w  ww .j  ava  2 s  . c  o  m*/
 */
private void animateOut(final FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }

    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(0.0F).scaleY(0.0F).alpha(0.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(),
                android.R.anim.fade_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                floatingActionButton.setVisibility(View.GONE);
            }

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

From source file:io.amira.zen.core.ZenFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    if (nextAnim != 0) {
        Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override//from   w  w  w . ja v  a 2s .  c  om
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (isNew) {
                    getElements();
                    buildElements();
                    isNew = false;
                }
                renderMap();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        return anim;
    } else {
        return super.onCreateAnimation(transit, enter, nextAnim);
    }
}

From source file:com.orangemoo.com.beta.widget.ScrollFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = true;
                    }/*  w w  w . j a  v  a2 s.  c o  m*/

                    public void onAnimationCancel(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.abc_fade_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

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

From source file:com.koma.music.detail.DetailsActivity.java

public void init() {
    if (getIntent() != null) {
        mWhichPage = getIntent().getIntExtra(Constants.WHICH_DETAIL_PAGE, Constants.ALBUM_DETAIL);
    }//from  ww  w  . j a v  a 2  s.c o  m

    setSupportActionBar(mToolbar);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mToolbar.post(new Runnable() {
        @Override
        public void run() {
            Animation animation = AnimationUtils.loadAnimation(DetailsActivity.this, R.anim.toolbar_slide_in);
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    mToolbar.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animation animation) {

                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            mToolbar.startAnimation(animation);
        }
    });

    QuickControlFragment quickControlFragment = (QuickControlFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_playback_controls);

    new QuickControlPresenter(quickControlFragment);

    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.container);

    if (fragment != null) {
        return;
    }

    Bundle bundle;

    switch (mWhichPage) {

    case Constants.RECENTLY_ADDED:
        mTitle = getResources().getString(R.string.recently_add);
        collapsingToolbarLayout.setTitle(mTitle);

        fragment = new RecentlyAddedFragment();
        break;
    case Constants.RECENTLY_PLAYED:
        mTitle = getResources().getString(R.string.recently_play);
        collapsingToolbarLayout.setTitle(mTitle);

        fragment = new RecentlyPlayFragment();
        break;
    case Constants.MY_FAVORITE:
        mTitle = getResources().getString(R.string.my_favorite);
        collapsingToolbarLayout.setTitle(mTitle);

        fragment = new MyFavoriteFragment();
        break;
    case Constants.ALBUM_DETAIL:
        mTargetId = getIntent().getLongExtra(Constants.ALBUM_ID, -1);
        mTitle = getIntent().getStringExtra(Constants.ALBUM_NAME);
        collapsingToolbarLayout.setTitle(mTitle);
        fragment = new AlbumDetailsFragment();
        bundle = new Bundle();
        bundle.putLong(Constants.ALBUM_ID, mTargetId);
        fragment.setArguments(bundle);
        break;
    case Constants.ARTIST_DETAIL:
        mTargetId = getIntent().getLongExtra(Constants.ARTIST_ID, -1);
        mTitle = getIntent().getStringExtra(Constants.ARTIST_NAME);
        collapsingToolbarLayout.setTitle(mTitle);
        fragment = new ArtistDetailFragment();
        bundle = new Bundle();
        bundle.putLong(Constants.ARTIST_ID, mTargetId);
        fragment.setArguments(bundle);
        break;
    default:
        break;
    }

    getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
}