Example usage for android.view.animation AnimationSet AnimationSet

List of usage examples for android.view.animation AnimationSet AnimationSet

Introduction

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

Prototype

public AnimationSet(boolean shareInterpolator) 

Source Link

Document

Constructor to use when building an AnimationSet from code

Usage

From source file:org.videolan.myvlc.core.gui.about.AboutMainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about_main, container, false);
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");
    String revision = Util.readAsset("revision.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override//from  ww w  .  j av  a 2  s. c  om
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    return v;
}

From source file:eu.thedarken.rootvalidator.ValidatorFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    AnimationSet set = new AnimationSet(true);
    Animation fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setDuration(350);/*from  ww w  . ja v  a 2 s. c  om*/
    set.addAnimation(fadeIn);
    Animation dropDown = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    dropDown.setDuration(400);
    set.addAnimation(dropDown);
    LayoutAnimationController controller = new LayoutAnimationController(set, 0.2f);
    mRecyclerView.setLayoutAnimation(controller);

    mFab.attachToRecyclerView(mRecyclerView);
    mFab.setVisibility(View.INVISIBLE);
    mEmptyStartView.setVisibility(View.GONE);
    mEmptyWorkingView.setVisibility(View.GONE);
    mListContainer.addView(mEmptyStartView);
    mListContainer.addView(mEmptyWorkingView);
    mRecyclerView.setEmptyView(mEmptyStartView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}

From source file:com.example.fragment.ScreenSlidePageFragment.java

public void startAnimation() {
    // SELECT LAYER
    ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;/*from  w  ww  .j a va 2  s .  c  o m*/
    float toX = -8.0f / 100.0f;//0.0f;
    float fromX = 0.0f;//-8.0f / 100.0f;
    float toY = 0.0f;
    float fromY = 29.0f / 100.0f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(2000);
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
}

From source file:org.videolan.vlc.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("VLC " + BuildConfig.VERSION_NAME);
    View v = inflater.inflate(R.layout.about, container, false);

    View aboutMain = v.findViewById(R.id.about_main);
    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = getString(R.string.build_revision);
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = getString(R.string.build_time);
    String builder = getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/* ww  w  . java 2  s.co m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    List<View> lists = Arrays.asList(aboutMain, t);
    String[] titles = new String[] { getString(R.string.about), getString(R.string.licence) };
    mViewPager = (ViewPager) v.findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
    mViewPager.setAdapter(new AudioPagerAdapter(lists, titles));

    mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
    mTabLayout.setupWithViewPager(mViewPager);

    return v;
}

From source file:org.videolan.vlc2.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("VLC " + getVersion(getActivity()));

    View v = inflater.inflate(R.layout.about, container, false);

    mTabHost = (TabHost) v.findViewById(android.R.id.tabhost);
    mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.fling_view_group);

    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = Util.readAsset("revision.txt", "Unknown revision");
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*from w  w w.j  av  a 2s .  c  o  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    mTabHost.setup();

    addNewTab(mTabHost, "about", getResources().getString(R.string.about));
    addNewTab(mTabHost, "licence", getResources().getString(R.string.licence));

    mTabHost.setCurrentTab(mCurrentTab);
    mFlingViewGroup.snapToScreen(mCurrentTab);

    mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            mCurrentTab = mTabHost.getCurrentTab();
            mFlingViewGroup.smoothScrollTo(mCurrentTab);
        }
    });

    mFlingViewGroup.setOnViewSwitchedListener(new FlingViewGroup.ViewSwitchListener() {
        @Override
        public void onSwitching(float progress) {
        }

        @Override
        public void onSwitched(int position) {
            mTabHost.setCurrentTab(position);
        }

        @Override
        public void onTouchDown() {
        }

        @Override
        public void onTouchUp() {
        }

        @Override
        public void onTouchClick() {
        }

        @Override
        public void onBackSwitched() {
            MainActivity activity = (MainActivity) getActivity();
            activity.popSecondaryFragment();
        }
    });

    return v;
}

From source file:com.example.testtab.fragment.GalleryPageFragment.java

public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
    this.mImageView.setImageResource(this.mThumbIds[position]);

    if (this.mThumbIds[position] != null) {
        AnimationSet set = new AnimationSet(true);

        AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);

        set.addAnimation(alpha);/*from w w  w .  j  a v  a2 s.c  om*/
        set.setDuration(500);
        set.setFillAfter(true);

        this.mImageView.startAnimation(set);
    }

}

From source file:com.capricorn.ArcMenu.java

private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);/*from w  ww .  j  a  v  a2 s. com*/
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void initializeFab(View rootView) {
    final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container);
    final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar);
    final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar);
    Fab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override// ww  w .  ja va 2 s.c o m
        public void onClick(View v) {

            //Menu Button Icon Animation
            //Setting up necessary variables
            long animationDuration = 500;
            float containerHeight = buttonContainer.getHeight();
            float containerCenterY = containerHeight / 2;
            float containerCenterX = buttonContainer.getWidth() / 2;
            float topBarCenter = topBar.getTop() + topBar.getHeight() / 2;
            float widthOfBar = topBar.getWidth();
            float heightOfBar = topBar.getHeight();
            final float distanceBetweenBars = (containerCenterY - topBarCenter);

            /**
             *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties
             *and objects at the same time. Also, will try to break intialization into smaller functions.
             */

            //Setting up animations of hamburger bars and rotation

            /**
             * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar.
             * Y Translation is 1/2 the height of the hamburger bar minus the distance.
             * Subtracting the distance from the height because the distance between bars is
             * calculated of the exact center of the button.
             * With out the subtraction the bar would translate slightly below the middle bar.
             */
            float yTranslation = heightOfBar / 2 - distanceBetweenBars;
            float xTranslation = widthOfBar / 2 + heightOfBar / 2;
            TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars);
            topBarTranslationAnim.setDuration((long) (animationDuration * 0.8));
            topBarTranslationAnim.setFillAfter(true);

            //Animation for bottom hamburger bar. Translates and Rotates to create 'X'
            AnimationSet bottomBarAnimation = new AnimationSet(true);
            bottomBarAnimation.setFillAfter(true);

            //Rotate to create cross. (The cross becomes the X after the button rotation completes"
            RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f,
                    Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f);
            bottomBarRotationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarRotationAnimation);

            //Translate to correct X alignment
            TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE,
                    -yTranslation);
            bottomBarTranslationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarTranslationAnimation);

            //Button Specific Animations
            //Rotate Button Container
            RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            containerRotationAnimation.setDuration(animationDuration);
            containerRotationAnimation.setFillAfter(true);

            //Animate change of button color between Active and Disabled colors that have been
            //defined in color.xml
            int activeColor = getResources().getColor(R.color.active_button);
            int disabledColor = getResources().getColor(R.color.disabled_button);

            //Need to use ValueAnimator because property animator does not support BackgroundTint
            ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor);
            buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue()));
                }
            });
            buttonColorAnimation.setDuration(animationDuration);

            //Start all the animations
            topBar.startAnimation(topBarTranslationAnim);
            bottomBar.startAnimation(bottomBarAnimation);
            buttonContainer.startAnimation(containerRotationAnimation);
            buttonColorAnimation.start();

            //Toogle mMenu open and closed
            if (mMenu.isOpen()) {
                //If mMenu is open, do the reverse of the animation
                containerRotationAnimation
                        .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator()));
                mMenu.close();
            } else {
                bottomBarAnimation.setInterpolator(new AccelerateInterpolator());
                mMenu.open();
            }
        }
    });
}

From source file:com.ycdyng.onemulti.MultiFragment.java

@Override
public Animation onCreateAnimation(final int transit, final boolean enter, final int nextAnim) {
    if (nextAnim == 0) {
        return null;
    }/*w  w w .  j ava 2s.  c o m*/
    //        if(enter) {
    //            if(nextAnim == StartAnimations[0]) {
    //                ViewCompat.setTranslationZ(getView(), 1.0f);
    //            } else {
    //                ViewCompat.setTranslationZ(getView(), 0.0f);
    //            }
    //        } else {
    //            if(nextAnim == BackAnimations[0]) {
    //                ViewCompat.setTranslationZ(getView(), 1.0f);
    //            } else {
    //                ViewCompat.setTranslationZ(getView(), 0.0f);
    //            }
    //        }
    Animation animation = AnimationUtils.loadAnimation(getActivity(), nextAnim);
    animation.setAnimationListener(new Animation.AnimationListener() {

        private int mLayerType;

        @Override
        public void onAnimationStart(Animation animation) {
            if (getView() != null) {
                mLayerType = getView().getLayerType();
                getView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            //                if(getView() != null) {
            //                    getView().setLayerType(mLayerType, null);
            //                    getView().post(new Runnable() {
            //                        @Override
            //                        public void run() {
            //                            if(getView() != null) {
            //                                ViewCompat.setTranslationZ(getView(), 0.0f);
            //                            }
            //                        }
            //                    });
            //                }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    // NOTE: the animation must be added to an animation set in order for the listener
    // to work on the exit animation
    AnimationSet animSet = new AnimationSet(true);
    animSet.addAnimation(animation);
    return animSet;
}

From source file:nu.yona.app.ui.pincode.BasePasscodeActivity.java

/**
 * Initialize animation.//  w ww .j a  va 2  s. c om
 */
protected void initializeAnimation() {
    final Animation in = new AlphaAnimation(0.0f, 1.0f);
    in.setDuration(AppConstant.ANIMATION_DURATION);
    animationView = new AnimationSet(true);
    in.setStartOffset(AppConstant.TIMER_DELAY);
    animationView.addAnimation(in);
}