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:Main.java

private static Animator setRepeatableAnim(Activity activity, View target, final int duration, int animRes) {
    final Animator anim = AnimatorInflater.loadAnimator(activity, animRes);
    anim.setDuration(duration);//from w  w w.  j  av a 2s . co  m
    anim.setTarget(target);
    return anim;
}

From source file:Main.java

public static Animator xmlFileLoadAnimator(Context context, int id, View view) {
    Animator animator = AnimatorInflater.loadAnimator(context, id);
    animator.setTarget(view);/*  ww w  .j  av a2 s .co m*/
    return animator;
}

From source file:com.microsoft.mimickeralarm.mimics.MimicStateBanner.java

public MimicStateBanner(final Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mSuccessColor = ContextCompat.getColor(context, R.color.green3);
    mFailureColor = ContextCompat.getColor(context, R.color.dark3);

    mEnterLeftAnimation = (AnimatorSet) AnimatorInflater.loadAnimator(context,
            R.animator.game_success_animator);
    mEnterLeftAnimation.setTarget(this);
}

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);//  w ww  . j  a  va 2  s  .c o  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) {
            generateRandomData();
        }

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

    mAnimatorSet.start();
}

From source file:com.example.android.walkmyandroid.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLocationButton = (Button) findViewById(R.id.button_location);
    mLocationTextView = (TextView) findViewById(R.id.textview_location);
    mAndroidImageView = (ImageView) findViewById(R.id.imageview_android);

    // Initialize the FusedLocationClient.
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

    // Set up the animation.
    mRotateAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.rotate);
    mRotateAnim.setTarget(mAndroidImageView);

    // Restore the state if the activity is recreated.
    if (savedInstanceState != null) {
        mTrackingLocation = savedInstanceState.getBoolean(TRACKING_LOCATION_KEY);
    }// w  w  w  . j  av  a  2 s . c  o m

    // Set the listener for the location button.
    mLocationButton.setOnClickListener(new View.OnClickListener() {
        /**
         * Toggle the tracking state.
         * @param v The track location button.
         */
        @Override
        public void onClick(View v) {
            if (!mTrackingLocation) {
                startTrackingLocation();
                mTrackingLocation = true;
            } else {
                stopTrackingLocation();
                mTrackingLocation = false;
            }
        }
    });

    // Initialize the location callbacks.
    mLocationCallback = new LocationCallback() {
        /**
         * This is the callback that is triggered when the
         * FusedLocationClient updates your location.
         * @param locationResult The result containing the device location.
         */
        @Override
        public void onLocationResult(LocationResult locationResult) {
            // If tracking is turned on, reverse geocode into an address
            if (mTrackingLocation) {
                new FetchAddressTask().execute(locationResult.getLastLocation());
            }
        }
    };
}

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);/* ww  w.  ja  v  a2s  .  c o m*/
    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: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);/* ww w .j a  va2 s. com*/
    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.google.cloud.solutions.griddler.android.ui.game.LetterView.java

private void init(Context context) {
    LayoutInflater.from(context).inflate(R.layout.fragment_game_letter, this);
    letterTextView = (TextView) this.findViewById(R.id.fragment_game_letter_letterTextView);

    letterTextView.setOnTouchListener(this);

    bounceAnimation = AnimationUtils.loadAnimation(context, R.animator.game_letter_bounce_animation);

    selectedAnimationSet = (AnimatorSet) AnimatorInflater.loadAnimator(this.getContext(),
            R.animator.game_letter_selected);
    selectedAnimationSet.setTarget(this);
    selectedAnimationSet.addListener(new AnimatorListener() {

        @Override//from w  w  w . ja v  a  2  s  . c  o m
        public void onAnimationStart(Animator arg0) {
            letterTextView.setTextColor(getContext().getResources().getColor(R.color.white));
            letterTextView.setBackgroundColor(getContext().getResources().getColor(R.color.red));
            letterTextView.setBackgroundResource(R.drawable.game_letter_roundedcorner_red);
        }

        @Override
        public void onAnimationRepeat(Animator arg0) {
        }

        @Override
        public void onAnimationEnd(Animator arg0) {
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
        }
    });

    unselectedAnimationSet = (AnimatorSet) AnimatorInflater.loadAnimator(this.getContext(),
            R.animator.game_letter_unselected);
    unselectedAnimationSet.setTarget(this);
    unselectedAnimationSet.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator arg0) {
            letterTextView.setTextColor(getContext().getResources().getColor(R.color.black));
            letterTextView.setBackgroundColor(getContext().getResources().getColor(R.color.white));
            letterTextView.setBackgroundResource(R.drawable.game_letter_roundedcorner);
        }

        @Override
        public void onAnimationRepeat(Animator arg0) {
        }

        @Override
        public void onAnimationEnd(Animator arg0) {
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
        }
    });

    resetAnimationSet = (AnimatorSet) AnimatorInflater.loadAnimator(this.getContext(),
            R.animator.game_letter_reset);
    resetAnimationSet.setTarget(this);
    resetAnimationSet.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator arg0) {
        }

        @Override
        public void onAnimationRepeat(Animator arg0) {
        }

        @Override
        public void onAnimationEnd(Animator arg0) {
            letterTextView.setTextColor(getContext().getResources().getColor(R.color.black));
            letterTextView.setBackgroundColor(getContext().getResources().getColor(R.color.white));
            letterTextView.setBackgroundResource(R.drawable.game_letter_roundedcorner);
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
        }
    });

}

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

/**
 * Loads an {@link Animator} object from a context
 *
 * @param context Application context used to access resources
 * @param id      The resource id of the animation to load
 * @return The animator object reference by the specified id
 * @throws NotFoundException when the animation cannot be loaded
 *///from w  w  w  .j a  va 2  s.com
public static Animator loadAnimator(Context context, @AnimatorRes int id) throws NotFoundException {
    Animator objectAnimator;
    // Since AVDC will fall back onto AVD when API is >= 24, therefore, PathParser will need
    // to match the accordingly to be able to call into the right setter/ getter for animation.
    if (Build.VERSION.SDK_INT >= 24) {
        objectAnimator = AnimatorInflater.loadAnimator(context, id);
    } else {
        objectAnimator = loadAnimator(context, context.getResources(), context.getTheme(), id);
    }
    return objectAnimator;
}

From source file:de.baumann.thema.RequestActivity.java

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

    setContentView(R.layout.request_grid);
    switcherLoad = (ViewSwitcher) findViewById(R.id.viewSwitcherLoadingMain);
    context = this;

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }// ww w. j a v  a2  s  .  c o  m

    if (savedInstanceState == null) {

        //Loading Logo Animation
        ImageView logo = (ImageView) findViewById(R.id.imageViewLogo);
        ObjectAnimator logoAni = (ObjectAnimator) AnimatorInflater.loadAnimator(context,
                R.animator.request_flip);
        logoAni.setRepeatCount(Animation.INFINITE);
        logoAni.setRepeatMode(Animation.RESTART);
        logoAni.setTarget(logo);
        logoAni.setDuration(2000);
        logoAni.start();

        taskList.execute();
    } else {
        populateView(list_activities_final);
        switcherLoad.showNext();
    }
}