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:com.yahoo.mobile.client.android.yodel.ui.ImageGalleryActivity.java

@SuppressLint("NewApi")
public void hideSystemUi() {

    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    Animator anim = AnimatorInflater.loadAnimator(this, R.animator.fade_hide);
    anim.setTarget(mCaptionPagerIndicator);
    anim.start();/* w w w .j a va 2  s.  c o m*/

    getSupportActionBar().hide();
}

From source file:com.yahoo.mobile.client.android.yodel.ui.ImageGalleryActivity.java

@SuppressLint("NewApi")
public void showSystemUi() {
    getWindow().getDecorView()// w w  w.ja  v a2s .  c  om
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_FULLSCREEN // keep status bar hidden
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

    Animator anim = AnimatorInflater.loadAnimator(this, R.animator.fade_show);
    anim.setTarget(mCaptionPagerIndicator);
    anim.start();

    getSupportActionBar().show();
}

From source file:com.hadis.mylunbo.carrousel.CircleIndicator.java

private Animator createAnimatorOut(Context context) {
    return AnimatorInflater.loadAnimator(context, mAnimatorResId);
}

From source file:com.hadis.mylunbo.carrousel.CircleIndicator.java

private Animator createAnimatorIn(Context context) {
    Animator animatorIn;//from  w w  w . ja v a  2s . c o m
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}

From source file:com.rukiasoft.androidapps.cocinaconroll.ui.RecipeListRecyclerViewAdapter.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void flipCard(final View card) {
    final View front = frontCard;
    final View back = backCard;
    final AnimatorSet flipCard = (card.getRotationY() == 0)
            ? (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_half)
            : (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_full);
    final AnimatorSet disappear = (AnimatorSet) AnimatorInflater.loadAnimator(mContext,
            R.animator.view_disappear);/*  w  w w .j av a  2  s.com*/
    //final AnimatorSet flipPositive = (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.card_flip_rotate_full);
    final AnimatorSet appear = (AnimatorSet) AnimatorInflater.loadAnimator(mContext, R.animator.view_appear);
    flipCard.setTarget(card);
    disappear.setTarget(front);
    //flipPositive.setTarget(card);
    appear.setTarget(back);
    //setLeftIn.setTarget(backView);
    flipCard.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            disappear.start();
            appear.start();
            back.setVisibility(View.VISIBLE);
            back.setAlpha(0);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            front.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

    flipCard.start();
}

From source file:com.wnafee.vector.compat.AnimatedVectorDrawable.java

public void inflate(Context c, Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme)
        throws XmlPullParserException, IOException {

    int eventType = parser.getEventType();
    float pathErrorScale = 1;
    while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
            final String tagName = parser.getName();
            if (ANIMATED_VECTOR.equals(tagName)) {
                final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawable);
                int drawableRes = a.getResourceId(R.styleable.AnimatedVectorDrawable_android_drawable, 0);
                if (drawableRes != 0) {
                    VectorDrawable vectorDrawable = (VectorDrawable) VectorDrawable.create(res, drawableRes)
                            .mutate();/*from www.ja  va  2 s. c o m*/
                    vectorDrawable.setAllowCaching(false);
                    pathErrorScale = vectorDrawable.getPixelSize();
                    mAnimatedVectorState.mVectorDrawable = vectorDrawable;
                }
                a.recycle();
            } else if (TARGET.equals(tagName)) {
                final TypedArray a = obtainAttributes(res, theme, attrs,
                        R.styleable.AnimatedVectorDrawableTarget);
                final String target = a.getString(R.styleable.AnimatedVectorDrawableTarget_android_name);

                int id = a.getResourceId(R.styleable.AnimatedVectorDrawableTarget_android_animation, 0);
                if (id != 0) {
                    //path animators require separate handling
                    Animator objectAnimator;
                    if (isPath(target)) {
                        objectAnimator = getPathAnimator(c, res, theme, id, pathErrorScale);
                    } else {
                        objectAnimator = AnimatorInflater.loadAnimator(c, id);
                    }
                    setupAnimatorsForTarget(target, objectAnimator);
                }
                a.recycle();
            }
        }

        eventType = parser.next();
    }
}

From source file:com.google.android.apps.gutenberg.ScannerActivity.java

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();//from  www. j av  a2 s .  co  m
    }
    final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover);
    cover.setVisibility(View.VISIBLE);
    final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer);
    final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;
    holder.setWillAnimate(true);
    holder.bind(checkin, mImageLoader);
    holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0));
    float elevation = getResources().getDimension(R.dimen.popup_elevation);
    ViewCompat.setTranslationZ(holder.itemView, elevation);
    holder.setLines(false, false);
    layer.addView(holder.itemView, lp);
    // Interpolator for animators
    FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator();
    // Pop-up
    Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up);
    popUpAnim.setTarget(holder.itemView);
    popUpAnim.setInterpolator(interpolator);
    popUpAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            holder.animateCheckin();
        }
    });
    // Wait
    ObjectAnimator waitAnim = new ObjectAnimator();
    waitAnim.setTarget(holder.itemView);
    waitAnim.setPropertyName("translationY");
    waitAnim.setFloatValues(0.f, 0.f);
    waitAnim.setDuration(2000);
    // Slide-down
    ObjectAnimator slideDownAnim = new ObjectAnimator();
    slideDownAnim.setTarget(holder.itemView);
    slideDownAnim.setPropertyName("translationY");
    slideDownAnim.setFloatValues(0.f, calcSlideDistance());
    slideDownAnim.setInterpolator(interpolator);
    // Landing anim
    ObjectAnimator landingAnim = new ObjectAnimator();
    landingAnim.setTarget(holder.itemView);
    landingAnim.setPropertyName("translationZ");
    landingAnim.setFloatValues(elevation, 0.f);
    landingAnim.setInterpolator(interpolator);
    landingAnim.setDuration(500);
    // Play the animators
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(interpolator);
    set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            clean();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            clean();
        }

        private void clean() {
            mLastAnimator = null;
            layer.removeAllViews();
            cover.setVisibility(View.INVISIBLE);
        }
    });
    mLastAnimator = set;
    set.start();
}

From source file:eu.intermodalics.tango_ros_streamer.activities.RunningActivity.java

private void switchRosLight(final RosStatus status) {
    runOnUiThread(new Runnable() {
        @Override//from w  ww  .  java 2s.  c o  m
        public void run() {
            if (status == RosStatus.UNKNOWN) {
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_orange_light));
            } else if (status == RosStatus.MASTER_CONNECTED) {
                // Turn ROS light to green.
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_green_light));
                // Dismiss ROS reconnection snackbar if necessary.
                if (mSnackbarRosReconnection != null && mSnackbarRosReconnection.isShown()) {
                    mSnackbarRosReconnection.dismiss();
                }
                // Set settings icon color to white.
                mToolbarMenu.findItem(R.id.settings).setIcon(R.drawable.ic_settings_white_24dp);
            } else if (status == RosStatus.MASTER_NOT_CONNECTED) {
                // Turn ROS light to red.
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_red_light));
                // Show snackbar with ROS reconnection button.
                mSnackbarRosReconnection = Snackbar.make(findViewById(android.R.id.content),
                        getString(R.string.snackbar_text_reconnect_ros), Snackbar.LENGTH_INDEFINITE);
                mSnackbarRosReconnection.setAction(getString(R.string.snackbar_action_text_reconnect_ros),
                        new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                mRunLocalMaster = mSharedPref
                                        .getBoolean(getString(R.string.pref_master_is_local_key), false);
                                mMasterUri = mSharedPref.getString(getString(R.string.pref_master_uri_key),
                                        getResources().getString(R.string.pref_master_uri_default));
                                mUriTextView.setText(mMasterUri);
                                initAndStartRosJavaNode();
                            }
                        });
                View snackBarView = mSnackbarRosReconnection.getView();
                snackBarView.setBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
                mSnackbarRosReconnection.show();
                // Highlight ROS Master URI.
                AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(RunningActivity.this,
                        R.animator.master_uri_text_animation);
                set.setTarget(mUriTextView);
                set.start();
                // Set settings icon color to red.
                mToolbarMenu.findItem(R.id.settings).setIcon(R.drawable.ic_settings_red_24dp);
            }
        }
    });
}

From source file:android.support.graphics.drawable.AnimatedVectorDrawableCompat.java

@Override
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme)
        throws XmlPullParserException, IOException {
    if (mDelegateDrawable != null) {
        DrawableCompat.inflate(mDelegateDrawable, res, parser, attrs, theme);
        return;//w w  w.  j a  v a2 s .  c om
    }
    int eventType = parser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
            final String tagName = parser.getName();
            if (DBG_ANIMATION_VECTOR_DRAWABLE) {
                Log.v(LOGTAG, "tagName is " + tagName);
            }
            if (ANIMATED_VECTOR.equals(tagName)) {
                final TypedArray a = obtainAttributes(res, theme, attrs,
                        AndroidResources.styleable_AnimatedVectorDrawable);

                int drawableRes = a.getResourceId(AndroidResources.styleable_AnimatedVectorDrawable_drawable,
                        0);
                if (DBG_ANIMATION_VECTOR_DRAWABLE) {
                    Log.v(LOGTAG, "drawableRes is " + drawableRes);
                }
                if (drawableRes != 0) {
                    VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(res, drawableRes, theme);
                    vectorDrawable.setAllowCaching(false);
                    vectorDrawable.setCallback(mCallback);
                    if (mAnimatedVectorState.mVectorDrawable != null) {
                        mAnimatedVectorState.mVectorDrawable.setCallback(null);
                    }
                    mAnimatedVectorState.mVectorDrawable = vectorDrawable;
                }
                a.recycle();
            } else if (TARGET.equals(tagName)) {
                final TypedArray a = res.obtainAttributes(attrs,
                        AndroidResources.styleable_AnimatedVectorDrawableTarget);
                final String target = a.getString(AndroidResources.styleable_AnimatedVectorDrawableTarget_name);

                int id = a.getResourceId(AndroidResources.styleable_AnimatedVectorDrawableTarget_animation, 0);
                if (id != 0) {
                    if (mContext != null) {
                        Animator objectAnimator = AnimatorInflater.loadAnimator(mContext, id);
                        setupAnimatorsForTarget(target, objectAnimator);
                    } else {
                        throw new IllegalStateException("Context can't be null when inflating" + " animators");
                    }
                }
                a.recycle();
            }
        }

        eventType = parser.next();
    }
}

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

boolean startLogoAnimation() {
    Animator animator = null;/*from   ww w. j av  a  2s.c  om*/
    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;
}