Example usage for android.animation AnimatorInflater loadAnimator

List of usage examples for android.animation AnimatorInflater loadAnimator

Introduction

In this page you can find the example usage for android.animation AnimatorInflater loadAnimator.

Prototype

public static Animator loadAnimator(Context context, @AnimatorRes int id) throws NotFoundException 

Source Link

Document

Loads an Animator object from a resource

Usage

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

private boolean startLogoAnimation() {
    Animator animator = null;//from   w ww.  ja v a  2 s. c o  m
    if (mLogoResourceId != 0) {
        mLogoView.setVisibility(View.VISIBLE);
        mLogoView.setImageResource(mLogoResourceId);
        Animator inAnimator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_logo_enter);
        Animator outAnimator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_logo_exit);
        outAnimator.setStartDelay(LOGO_SPLASH_PAUSE_DURATION_MS);
        AnimatorSet logoAnimator = new AnimatorSet();
        logoAnimator.playSequentially(inAnimator, outAnimator);
        logoAnimator.setTarget(mLogoView);
        animator = logoAnimator;
    } else {
        animator = onCreateLogoAnimation();
    }
    if (animator != null) {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (getActivity() != null) {
                    startEnterAnimation();
                }
            }
        });
        animator.start();
        return true;
    }
    return false;
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

private static ValueAnimator loadAnimator(Context context, int resId) {
    ValueAnimator animator = (ValueAnimator) AnimatorInflater.loadAnimator(context, resId);
    animator.setDuration(animator.getDuration() * ANIMATION_MULTIPLIER);
    return animator;
}

From source file:com.rbware.github.androidcouchpotato.app.OnboardingSupportFragment.java

void startEnterAnimation() {
    mEnterTransitionFinished = true;/*from   w  ww.j a v a  2s.c o m*/
    initializeViews(getView());
    List<Animator> animators = new ArrayList<>();
    Animator animator = AnimatorInflater.loadAnimator(getActivity(),
            R.animator.lb_onboarding_page_indicator_enter);
    animator.setTarget(getPageCount() <= 1 ? mStartButton : mPageIndicator);
    animators.add(animator);
    // Header title
    View view = getActivity().findViewById(R.id.title);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_title_enter);
    animator.setStartDelay(START_DELAY_TITLE_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Header description
    view = getActivity().findViewById(R.id.description);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_description_enter);
    animator.setStartDelay(START_DELAY_DESCRIPTION_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Customized animation by the inherited class.
    Animator customAnimator = onCreateEnterAnimation();
    if (customAnimator != null) {
        animators.add(customAnimator);
    }
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(animators);
    mAnimator.start();
    // Search focus and give the focus to the appropriate child which has become visible.
    getView().requestFocus();
}

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

private void startEnterAnimation() {
    mEnterTransitionFinished = true;//from   ww w  .jav a  2 s  . co  m
    initializeViews(getView());
    List<Animator> animators = new ArrayList<>();
    Animator animator = AnimatorInflater.loadAnimator(getActivity(),
            R.animator.lb_onboarding_page_indicator_enter);
    animator.setTarget(getPageCount() <= 1 ? mStartButton : mPageIndicator);
    animators.add(animator);
    // Header title
    View view = getActivity().findViewById(R.id.title);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_title_enter);
    animator.setStartDelay(START_DELAY_TITLE_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Header description
    view = getActivity().findViewById(R.id.description);
    view.setAlpha(0);
    animator = AnimatorInflater.loadAnimator(getActivity(), R.animator.lb_onboarding_description_enter);
    animator.setStartDelay(START_DELAY_DESCRIPTION_MS);
    animator.setTarget(view);
    animators.add(animator);
    // Customized animation by the inherited class.
    Animator customAnimator = onCreateEnterAnimation();
    if (customAnimator != null) {
        animators.add(customAnimator);
    }
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(animators);
    mAnimator.start();
    // Search focus and give the focus to the appropriate child which has become visible.
    getView().requestFocus();
}

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

/**
 * Called when the page changes./*from  w  ww  . java  2  s  .  co  m*/
 */
private void onPageChangedInternal(int previousPage) {
    if (mAnimator != null) {
        mAnimator.end();
    }
    mPageIndicator.onPageSelected(mCurrentPageIndex, true);

    List<Animator> animators = new ArrayList<>();
    // Header animation
    Animator fadeAnimator = null;
    if (previousPage < getCurrentPageIndex()) {
        // sliding to left
        animators.add(createAnimator(mTitleView, false, Gravity.START, 0));
        animators.add(fadeAnimator = createAnimator(mDescriptionView, false, Gravity.START,
                DESCRIPTION_START_DELAY_MS));
        animators.add(createAnimator(mTitleView, true, Gravity.END, HEADER_APPEAR_DELAY_MS));
        animators.add(createAnimator(mDescriptionView, true, Gravity.END,
                HEADER_APPEAR_DELAY_MS + DESCRIPTION_START_DELAY_MS));
    } else {
        // sliding to right
        animators.add(createAnimator(mTitleView, false, Gravity.END, 0));
        animators.add(fadeAnimator = createAnimator(mDescriptionView, false, Gravity.END,
                DESCRIPTION_START_DELAY_MS));
        animators.add(createAnimator(mTitleView, true, Gravity.START, HEADER_APPEAR_DELAY_MS));
        animators.add(createAnimator(mDescriptionView, true, Gravity.START,
                HEADER_APPEAR_DELAY_MS + DESCRIPTION_START_DELAY_MS));
    }
    final int currentPageIndex = getCurrentPageIndex();
    fadeAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mTitleView.setText(getPageTitle(currentPageIndex));
            mDescriptionView.setText(getPageDescription(currentPageIndex));
        }
    });

    // Animator for switching between page indicator and button.
    if (getCurrentPageIndex() == getPageCount() - 1) {
        mStartButton.setVisibility(View.VISIBLE);
        Animator navigatorFadeOutAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_page_indicator_fade_out);
        navigatorFadeOutAnimator.setTarget(mPageIndicator);
        navigatorFadeOutAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mPageIndicator.setVisibility(View.GONE);
            }
        });
        animators.add(navigatorFadeOutAnimator);
        Animator buttonFadeInAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_start_button_fade_in);
        buttonFadeInAnimator.setTarget(mStartButton);
        animators.add(buttonFadeInAnimator);
    } else if (previousPage == getPageCount() - 1) {
        mPageIndicator.setVisibility(View.VISIBLE);
        Animator navigatorFadeInAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_page_indicator_fade_in);
        navigatorFadeInAnimator.setTarget(mPageIndicator);
        animators.add(navigatorFadeInAnimator);
        Animator buttonFadeOutAnimator = AnimatorInflater.loadAnimator(getActivity(),
                R.animator.lb_onboarding_start_button_fade_out);
        buttonFadeOutAnimator.setTarget(mStartButton);
        buttonFadeOutAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mStartButton.setVisibility(View.GONE);
            }
        });
        animators.add(buttonFadeOutAnimator);
    }
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(animators);
    mAnimator.start();
    onPageChanged(mCurrentPageIndex, previousPage);
}

From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java

@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    final int animatorId = (enter) ? R.anim.translate_from_bottom_to_top : R.anim.translate_from_top_to_bottom;
    Animator animator = AnimatorInflater.loadAnimator(getActivity(), animatorId);
    return animator;
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

private Animator createAnimator(View v, int resourceId) {
    Animator animator = AnimatorInflater.loadAnimator(v.getContext(), resourceId);
    animator.setTarget(v);/*  w  ww.  ja  va 2s.  c  o  m*/
    return animator;
}

From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java

@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    Animator anim = null;/*from w w w. j  a va 2 s  .  c om*/
    if (showTransitionAnim) {
        if (nextAnim != 0)
            anim = AnimatorInflater.loadAnimator(getActivity(), nextAnim);
        showTransitionAnim = false;
    } else
        anim = AnimatorInflater.loadAnimator(getActivity(), R.animator.none);
    return anim;
}

From source file:android.app.FragmentManager.java

Animator loadAnimator(Fragment fragment, int transit, boolean enter, int transitionStyle) {
    Animator animObj = fragment.onCreateAnimator(transit, enter, fragment.mNextAnim);
    if (animObj != null) {
        return animObj;
    }//from  ww  w. jav  a2 s .  c  o  m

    if (fragment.mNextAnim != 0) {
        Animator anim = AnimatorInflater.loadAnimator(mActivity, fragment.mNextAnim);
        if (anim != null) {
            return anim;
        }
    }

    if (transit == 0) {
        return null;
    }

    int styleIndex = transitToStyleIndex(transit, enter);
    if (styleIndex < 0) {
        return null;
    }

    if (transitionStyle == 0 && mActivity.getWindow() != null) {
        transitionStyle = mActivity.getWindow().getAttributes().windowAnimations;
    }
    if (transitionStyle == 0) {
        return null;
    }

    TypedArray attrs = mActivity.obtainStyledAttributes(transitionStyle,
            com.android.internal.R.styleable.FragmentAnimation);
    int anim = attrs.getResourceId(styleIndex, 0);
    attrs.recycle();

    if (anim == 0) {
        return null;
    }

    return AnimatorInflater.loadAnimator(mActivity, anim);
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    final MainActivity mainActivity = (MainActivity) getActivity();
    Animator anim = null;//from w w  w  .  j a va2  s .  co m
    if (showTransitionAnim) {
        if (nextAnim != 0)
            anim = AnimatorInflater.loadAnimator(getActivity(), nextAnim);
        showTransitionAnim = false;
        if (anim != null)
            anim.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    if (mainActivity.drawer instanceof DrawerLayout)
                        ((DrawerLayout) mainActivity.drawer).closeDrawer(mainActivity.drawerView);
                    mainActivity.setDrawerListener(true);
                }

                @Override
                public void onAnimationCancel(Animator animator) {
                }

                @Override
                public void onAnimationStart(Animator animator) {
                    mainActivity.setDrawerListener(false);
                }

                @Override
                public void onAnimationRepeat(Animator animator) {
                }
            });
    } else
        anim = AnimatorInflater.loadAnimator(getActivity(), R.animator.none);
    return anim;
}