Example usage for android.animation ObjectAnimator setTarget

List of usage examples for android.animation ObjectAnimator setTarget

Introduction

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

Prototype

@Override
    public void setTarget(@Nullable Object target) 

Source Link

Usage

From source file:Main.java

private static ObjectAnimator getAnimator(Object target) {
    ObjectAnimator animator = new ObjectAnimator();
    animator.setTarget(target);
    return animator;
}

From source file:Main.java

public static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);//from  w w w. ja  v a 2  s. com
    cancelOnDestroyActivity(anim);
    return anim;
}

From source file:Main.java

public static ObjectAnimator ofInt(Object target, String propertyName, int... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setPropertyName(propertyName);//from www. j a v  a2s  .  co  m
    anim.setIntValues(values);
    cancelOnDestroyActivity(anim);
    return anim;
}

From source file:Main.java

public static ObjectAnimator ofFloat(Object target, String propertyName, float... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setPropertyName(propertyName);/* ww  w  .j  a  v a 2 s.co  m*/
    anim.setFloatValues(values);
    cancelOnDestroyActivity(anim);
    return anim;
}

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

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();//  w  ww .  j  a  va  2  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: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  ava  2s.c om*/

    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();
    }
}