Example usage for android.animation AnimatorSet setTarget

List of usage examples for android.animation AnimatorSet setTarget

Introduction

In this page you can find the example usage for android.animation AnimatorSet setTarget.

Prototype

@Override
public void setTarget(Object target) 

Source Link

Document

Sets the target object for all current #getChildAnimations() child animations of this AnimatorSet that take targets ( ObjectAnimator and AnimatorSet).

Usage

From source file:com.reddyetwo.hashmypass.app.TutorialIntroFragment.java

private void startAnimation() {
    // Load and set up individual animators
    AnimatorSet websiteAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_website);/*from   w  w w  .  j av  a 2 s  . c om*/
    websiteAnimator.setTarget(mWebsiteTextView);
    AnimatorSet masterKeyAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_master_key);
    masterKeyAnimator.setTarget(mIcMasterKeyView);
    AnimatorSet passwordAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_password);
    passwordAnimator.setTarget(mWebsitePasswordView);

    // Prepare set with all animators, set up repeating and random data
    mAnimatorSet = new AnimatorSet();
    mAnimatorSet.playTogether(websiteAnimator, masterKeyAnimator, passwordAnimator);
    mAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            generateRandomData();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mAnimatorSet != null) {
                mAnimatorSet.start();
            }
        }
    });

    mAnimatorSet.start();
}

From source file:com.reddyetwo.hashmypass.app.tutorial.TutorialIntroFragment.java

private void createAnimation() {
    // Load and set up individual animators
    AnimatorSet websiteAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_website);//from w  ww  .j a  v  a 2 s. co  m
    websiteAnimator.setTarget(mWebsiteTextView);
    AnimatorSet masterKeyAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_master_key);
    masterKeyAnimator.setTarget(mIcMasterKeyView);
    AnimatorSet passwordAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.intro_password);
    passwordAnimator.setTarget(mWebsitePasswordView);

    // Prepare set with all animators, set up repeating and random data
    mAnimatorSet = new AnimatorSet();
    mAnimatorSet.playTogether(websiteAnimator, masterKeyAnimator, passwordAnimator);
    mAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mAnimationCancelled = false;
            generateRandomData();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mAnimationCancelled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mAnimationCancelled) {
                mAnimatorSet.start();
            }
        }
    });
}

From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java

private AnimatorSet getEnterAnimtor(final View target) {
    ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.2f, 1f);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.2f, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.2f, 1f);
    AnimatorSet enter = new AnimatorSet();
    enter.setDuration(500);//  w  ww.  j av  a 2s .  co  m
    enter.setInterpolator(new LinearInterpolator());
    enter.playTogether(alpha, scaleX, scaleY);
    enter.setTarget(target);
    return enter;
}

From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java

private Animator getAnimator(View target) {
    AnimatorSet set = getEnterAnimtor(target);
    ValueAnimator bezierValueAnimator = getBezierValueAnimator(target);
    AnimatorSet finalSet = new AnimatorSet();
    finalSet.playSequentially(set);/*from w  ww  . ja  v  a 2s. c o m*/
    finalSet.playSequentially(set, bezierValueAnimator);
    finalSet.setInterpolator(interpolators[random.nextInt(4)]);
    finalSet.setTarget(target);
    return finalSet;
}

From source file:com.gudong.appkit.ui.helper.AppItemAnimator.java

private void animateAddImpl(final RecyclerView.ViewHolder viewHolder) {
    final View target = viewHolder.itemView;
    mAddAnimations.add(viewHolder);/*  w  w w. j a  v a 2  s. c  o  m*/
    final AnimatorSet animator = new AnimatorSet();
    animator.playTogether(ObjectAnimator.ofFloat(target, "translationX", -target.getMeasuredWidth(), 0, 0f),
            ObjectAnimator.ofFloat(target, "alpha", 0.5f, 1.0f));
    animator.setTarget(target);
    animator.setDuration(KEY_DURATION_TIME);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            dispatchAddStarting(viewHolder);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            ViewCompat.setAlpha(target, 1);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            animator.removeAllListeners();
            dispatchAddFinished(viewHolder);
            mAddAnimations.remove(viewHolder);
            dispatchFinishedWhenDone();
        }
    });
    animator.start();
}

From source file:com.nexus.nsnik.randomno.view.fragments.CoinTossFragment.java

private void animateCoin(Integer integer) {

    float scale = mResources.getDisplayMetrics().density;
    mCoinImage.setCameraDistance(8000 * scale);

    final AnimatorSet coinFlipOut = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.flip_out);//from   w  w  w. j  a  v  a 2  s. c om
    final AnimatorSet coinFlipIn = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.flip_in);

    final AnimatorSet textFlipOut = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.flip_out);
    final AnimatorSet textFlipIn = (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(),
            R.animator.flip_in);

    coinFlipOut.setTarget(mCoinImage);
    coinFlipIn.setTarget(mCoinImage);
    textFlipIn.setTarget(mCoinText);
    textFlipOut.setTarget(mCoinText);

    textFlipOut.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {

        }

        @Override
        public void onAnimationEnd(Animator animator) {
            setCoinFace(integer);
            coinFlipIn.start();
            textFlipIn.start();
        }

        @Override
        public void onAnimationCancel(Animator animator) {

        }

        @Override
        public void onAnimationRepeat(Animator animator) {

        }
    });

    coinFlipOut.start();
    textFlipOut.start();

}

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

private boolean startLogoAnimation() {
    Animator animator = null;/*from ww w. j a  v a  2s  .  com*/
    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:com.rbware.github.androidcouchpotato.app.OnboardingSupportFragment.java

boolean startLogoAnimation() {
    Animator animator = null;/* w ww . j  a  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: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  . jav  a2s  . 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:eu.intermodalics.tango_ros_streamer.activities.RunningActivity.java

private void switchRosLight(final RosStatus status) {
    runOnUiThread(new Runnable() {
        @Override//w  w w . ja v  a 2  s .  com
        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);
            }
        }
    });
}