Example usage for android.animation Animator setTarget

List of usage examples for android.animation Animator setTarget

Introduction

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

Prototype

public void setTarget(@Nullable Object target) 

Source Link

Document

Sets the target object whose property will be animated by this animation.

Usage

From source file:Main.java

public static Animator xmlFileLoadAnimator(Context context, int id, View view) {
    Animator animator = AnimatorInflater.loadAnimator(context, id);
    animator.setTarget(view);
    return animator;
}

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 .ja  v  a  2 s.  co m
    anim.setTarget(target);
    return anim;
}

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

@SuppressLint("NewApi")
public void showSystemUi() {
    getWindow().getDecorView()/*w w w . jav a2 s  .  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.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();//from   w w  w .j  a v  a  2  s .  c o m

    getSupportActionBar().hide();
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

private static Animator createAnimator(View v, int attrId) {
    Context ctx = v.getContext();
    TypedValue typedValue = new TypedValue();
    ctx.getTheme().resolveAttribute(attrId, typedValue, true);
    Animator animator = AnimatorInflater.loadAnimator(ctx, typedValue.resourceId);
    animator.setTarget(v);
    return animator;
}

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

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();/*from  w w w .j a v  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:com.hippo.vectorold.drawable.AnimatedVectorDrawable.java

private void setupAnimatorsForTarget(String name, Animator animator) {
    Object target = mAnimatedVectorState.mVectorDrawable.getTargetByName(name);
    animator.setTarget(target);
    if (mAnimatedVectorState.mAnimators == null) {
        mAnimatedVectorState.mAnimators = new ArrayList<>();
        mAnimatedVectorState.mTargetNameMap = new ArrayMap<>();
    }//from  www.  j  a  v a  2s.  c om
    mAnimatedVectorState.mAnimators.add(animator);
    mAnimatedVectorState.mTargetNameMap.put(animator, name);
    if (DBG_ANIMATION_VECTOR_DRAWABLE) {
        Log.v(LOGTAG, "add animator  for target " + name + " " + animator);
    }
}

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

private void setupAnimatorsForTarget(String name, Animator animator) {
    Object target = mAnimatedVectorState.mVectorDrawable.getTargetByName(name);
    animator.setTarget(target);
    if (mAnimatedVectorState.mAnimators == null) {
        mAnimatedVectorState.mAnimators = new ArrayList<Animator>();
        mAnimatedVectorState.mTargetNameMap = new ArrayMap<Animator, String>();
    }/*ww w. j  a v a2 s.co m*/
    mAnimatedVectorState.mAnimators.add(animator);
    mAnimatedVectorState.mTargetNameMap.put(animator, name);
    if (DBG_ANIMATION_VECTOR_DRAWABLE) {
        Log.v(LOGTAG, "add animator  for target " + name + " " + animator);
    }
}

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

private void setupAnimatorsForTarget(String name, Animator animator) {
    Object target = mAnimatedVectorState.mVectorDrawable.getTargetByName(name);
    animator.setTarget(target);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setupColorAnimator(animator);/*ww  w .  j  av a2 s. c  o  m*/
    }
    if (mAnimatedVectorState.mAnimators == null) {
        mAnimatedVectorState.mAnimators = new ArrayList<Animator>();
        mAnimatedVectorState.mTargetNameMap = new ArrayMap<Animator, String>();
    }
    mAnimatedVectorState.mAnimators.add(animator);
    mAnimatedVectorState.mTargetNameMap.put(animator, name);
    if (DBG_ANIMATION_VECTOR_DRAWABLE) {
        Log.v(LOGTAG, "add animator  for target " + name + " " + animator);
    }
}

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

private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) {
        animator.end();/*from   w  ww .j a  v a  2 s .c o  m*/
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}