Java Code Examples for android.animation.ObjectAnimator#setTarget()

The following examples show how to use android.animation.ObjectAnimator#setTarget() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RapidFloatingActionContentLabelList.java    From RapidFloatingActionButton with Apache License 2.0 6 votes vote down vote up
@Override
public void onExpandAnimator(AnimatorSet animatorSet) {
    int count = contentView.getChildCount();
    for (int i = 0; i < count; i++) {
        View rootView = contentView.getChildAt(i);
        ImageView iconIv = RFABViewUtil.obtainView(rootView, R.id.rfab__content_label_list_icon_iv);
        if (null == iconIv) {
            return;
        }
        ObjectAnimator animator = new ObjectAnimator();
        animator.setTarget(iconIv);
        animator.setFloatValues(45f, 0);
        animator.setPropertyName("rotation");
        animator.setInterpolator(mOvershootInterpolator);
        animator.setStartDelay((count * i) * 20);
        animatorSet.playTogether(animator);
    }
}
 
Example 2
Source File: CardStreamLinearLayout.java    From sensors-samples with Apache License 2.0 6 votes vote down vote up
private void handleViewSwipingIn(final View child, float deltaX, float deltaY) {
    ObjectAnimator animator = mAnimators.getSwipeInAnimator(child, deltaX, deltaY);
    if( animator != null ){
        animator.addListener(new EndAnimationWrapper() {
            @Override
            public void onAnimationEnd(Animator animation) {
                child.setTranslationY(0.f);
                child.setTranslationX(0.f);
            }
        });
    } else {
        child.setTranslationY(0.f);
        child.setTranslationX(0.f);
    }

    if( animator != null ){
        animator.setTarget(child);
        animator.start();
    }
}
 
Example 3
Source File: BezierPraiseAnimator.java    From kAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * 获取到点赞小图标动画
 *
 * @param target
 * @return
 */
private Animator getPraiseAnimator(View target) {
    // 获取贝塞尔曲线动画
    ValueAnimator bezierPraiseAnimator = getBezierPraiseAnimator(target);
    // 组合动画(旋转动画+贝塞尔曲线动画)旋转角度(200~720)
    int rotationAngle = mRandom.nextInt(520) + 200;
    ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(target, "rotation", 0,
            rotationAngle % 2 == 0 ? rotationAngle : -rotationAngle);
    rotationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    rotationAnimator.setTarget(target);

    // 组合动画
    AnimatorSet composeAnimator = new AnimatorSet();
    composeAnimator.play(bezierPraiseAnimator).with(rotationAnimator);
    composeAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    composeAnimator.setDuration(mAnimatorDuration);
    composeAnimator.setTarget(target);
    return composeAnimator;

}
 
Example 4
Source File: CardStreamLinearLayout.java    From android-play-places with Apache License 2.0 6 votes vote down vote up
private void handleViewSwipingOut(final View child, float deltaX, float deltaY) {
    ObjectAnimator animator = mAnimators.getSwipeOutAnimator(child, deltaX, deltaY);
    if( animator != null ){
        animator.addListener(new EndAnimationWrapper() {
            @Override
            public void onAnimationEnd(Animator animation) {
                removeView(child);
                notifyOnDismissEvent(child);
            }
        });
    } else {
        removeView(child);
        notifyOnDismissEvent(child);
    }

    if( animator != null ){
        animator.setTarget(child);
        animator.start();
    }
}
 
Example 5
Source File: RapidFloatingActionContentLabelList.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onCollapseAnimator(AnimatorSet animatorSet) {
    int count = contentView.getChildCount();
    for (int i = 0; i < count; i++) {
        View rootView = contentView.getChildAt(i);
        ImageView iconIv = RFABViewUtil.obtainView(rootView, R.id.rfab__content_label_list_icon_iv);
        if (null == iconIv) {
            return;
        }
        ObjectAnimator animator = new ObjectAnimator();
        animator.setTarget(iconIv);
        animator.setFloatValues(0, 45f);
        animator.setPropertyName("rotation");
        animator.setInterpolator(mOvershootInterpolator);
        animator.setStartDelay((count * i) * 20);
        animatorSet.playTogether(animator);
    }
}
 
Example 6
Source File: CardStreamLinearLayout.java    From android-BatchStepSensor with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void runInitialAnimations() {
    if( mAnimators == null )
        return;

    final int count = getChildCount();

    for (int index = 0; index < count; ++index) {
        final View child = getChildAt(index);
        ObjectAnimator animator =  mAnimators.getInitalAnimator(getContext());
        if( animator != null ){
            animator.setTarget(child);
            animator.start();
        }
    }
}
 
Example 7
Source File: UDAnimator.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
/**
 * build a copy of given animator
 *
 * @return
 */
public Animator build() {
    //这种方式clone出来的animator不能重复播放
    /* ObjectAnimator result = getAnimator().clone();//克隆一份
    setupListeners(result);
    result.setupStartValues();
    return result;*/

    ObjectAnimator self = this.getAnimator();
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(self.getTarget());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        anim.setAutoCancel(true);
    }
    if (self.getValues() != null) {
        anim.setValues(self.getValues());
    }
    anim.setInterpolator(self.getInterpolator());
    anim.setDuration(self.getDuration());
    anim.setStartDelay(self.getStartDelay());
    anim.setRepeatCount(self.getRepeatCount());
    anim.setRepeatMode(self.getRepeatMode());
    setupListeners(anim);
    return anim;
}
 
Example 8
Source File: CardStreamLinearLayout.java    From android-BatchStepSensor with Apache License 2.0 6 votes vote down vote up
private void handleViewSwipingOut(final View child, float deltaX, float deltaY) {
    ObjectAnimator animator = mAnimators.getSwipeOutAnimator(child, deltaX, deltaY);
    if( animator != null ){
        animator.addListener(new EndAnimationWrapper() {
            @Override
            public void onAnimationEnd(Animator animation) {
                removeView(child);
                notifyOnDismissEvent(child);
            }
        });
    } else {
        removeView(child);
        notifyOnDismissEvent(child);
    }

    if( animator != null ){
        animator.setTarget(child);
        animator.start();
    }
}
 
Example 9
Source File: MainKeyboardView.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
    if (resId == 0) {
        // TODO: Stop returning null.
        return null;
    }
    final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
            getContext(), resId);
    if (animator != null) {
        animator.setTarget(target);
    }
    return animator;
}
 
Example 10
Source File: LauncherAnimUtils.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public static ObjectAnimator ofPropertyValuesHolder(Object target,
        View view, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, view);
    return anim;
}
 
Example 11
Source File: LauncherAnimUtils.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public static ObjectAnimator ofPropertyValuesHolder(View target,
        PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, target);
    return anim;
}
 
Example 12
Source File: ProgressBarView.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public ProgressBarView(ContainerType containerType, ViewGroup container,
        XSharedPreferences prefs, ProgressBarController ctrl) {
    super(container.getContext());

    mContainerType = containerType;
    mCtrl = ctrl;

    mAnimated = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_ANIMATED, true);
    mCentered = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_CENTERED, false);
    mHeightPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_THICKNESS, 1),
            getResources().getDisplayMetrics());
    mEdgeMarginPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_MARGIN, 0),
            getResources().getDisplayMetrics());

    setScaleX(0f);
    setBackgroundColor(Color.WHITE);
    setVisibility(View.GONE);
    container.addView(this);

    mAnimator = new ObjectAnimator();
    mAnimator.setTarget(this);
    mAnimator.setInterpolator(new DecelerateInterpolator());
    mAnimator.setDuration(ANIM_DURATION);
    mAnimator.setRepeatCount(0);
}
 
Example 13
Source File: VolumeSliderView.java    From FuckingVolumeSlider with GNU General Public License v3.0 5 votes vote down vote up
private void initAnimator() {
    mPressAnimator = ObjectAnimator.ofFloat(this, DEGREE, 0, -45);
    mPressAnimator.setDuration(1000);

    mUpAnimator = new AnimatorSet();
    mDegreeAnimator = new ObjectAnimator();
    mDegreeAnimator.setTarget(this);
    mDegreeAnimator.setProperty(DEGREE);
    mBallAnimator = new ObjectAnimator();
    mBallAnimator.setTarget(this);
    mBallAnimator.setProperty(BALLLOCATION);
    mUpAnimator.playTogether(mDegreeAnimator, mBallAnimator);
}
 
Example 14
Source File: MainKeyboardView.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
    if (resId == 0) {
        // TODO: Stop returning null.
        return null;
    }
    final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
            getContext(), resId);
    if (animator != null) {
        animator.setTarget(target);
    }
    return animator;
}
 
Example 15
Source File: MainKeyboardView.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
    if (resId == 0) {
        // TODO: Stop returning null.
        return null;
    }
    final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
            getContext(), resId);
    if (animator != null) {
        animator.setTarget(target);
    }
    return animator;
}
 
Example 16
Source File: UDAnimator.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 设置target
 *
 * @param udView
 * @return
 */
public UDAnimator with(UDView udView) {
    ObjectAnimator animator = getAnimator();
    if (animator != null && udView != null && udView.getView() != null) {
        mTarget = udView;
        animator.setTarget(udView.getView());
    }
    return this;
}
 
Example 17
Source File: LauncherAnimUtils.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
public static ObjectAnimator ofFloat(View target, String propertyName, float... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setPropertyName(propertyName);
    anim.setFloatValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, target);
    return anim;
}
 
Example 18
Source File: LauncherAnimUtils.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
public static ObjectAnimator ofPropertyValuesHolder(Object target,
        View view, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, view);
    return anim;
}
 
Example 19
Source File: AnimatorFromXmlFragment.java    From AndroidAll with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    super.onClick(v);
    if (left == 0) {
        left = tvTarget.getLeft();
    }
    if (top == 0) {
        top = tvTarget.getTop();
    }
    switch (v.getId()) {
        case R.id.btn_start_1:
            ValueAnimator valueAnimator = (ValueAnimator) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.value_animtor);
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    int value = (int) animation.getAnimatedValue();
                    tvTarget.layout(
                            value + left,
                            value + top,
                            value + left + tvTarget.getWidth(),
                            value + top + tvTarget.getHeight());
                }
            });
            valueAnimator.start();
            break;
        case R.id.btn_start_2:
            ObjectAnimator objectAnimator = (ObjectAnimator) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.object_animtor);
            objectAnimator.setTarget(tvTarget);
            objectAnimator.start();
            break;

        case R.id.btn_start_3:
            AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.animtor_set);
            animatorSet.setTarget(tvTarget);
            animatorSet.start();
            break;
    }
}
 
Example 20
Source File: PicturePasswordView.java    From android-picturepassword with MIT License 4 votes vote down vote up
public PicturePasswordView( Context context, AttributeSet attrs )
{
	super( context, attrs );
	
	setScaleType( ScaleType.CENTER_CROP );
	
	mRandom = new Random();
	mSeed = mRandom.nextInt();
	
	mGridSize = DEFAULT_GRID_SIZE;
	
	///////////////////////
	// Initialize Paints //
	///////////////////////
	final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
	final float shadowOff = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 2, displayMetrics );
	
	mPaint = new Paint( Paint.LINEAR_TEXT_FLAG );
	
	mPaint.setColor( Color.WHITE );
	
	mPaint.setShadowLayer( 10, shadowOff, shadowOff, Color.BLACK );
	mPaint.setTextSize( TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, FONT_SIZE, displayMetrics ) );
	
	mPaint.setAntiAlias( true );

	mCirclePaint = new Paint( Paint.ANTI_ALIAS_FLAG );

	mCirclePaint.setColor( Color.argb( 255, 0x33, 0xb5, 0xe5 ) );
	
	mCirclePaint.setStyle( Paint.Style.STROKE );
	mCirclePaint.setStrokeWidth( 5 );
	
	mUnlockPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
	
	mTextBounds = new Rect();
	mPaint.getTextBounds( "8", 0, 1, mTextBounds );
	
	///////////////////////////
	// Initialize animations //
	///////////////////////////

	mScale = 1.0f;
	
	mAnimator = new ObjectAnimator();
	mAnimator.setTarget( this );
	mAnimator.setFloatValues( 0, 1 );
	mAnimator.setPropertyName( "scale" );
	mAnimator.setDuration( 200 );
	
	mCircleAnimator = new ObjectAnimator();
	mCircleAnimator.setTarget( this );
	mCircleAnimator.setPropertyName( "internalUnlockProgress" ); // ugh!
	mCircleAnimator.setDuration( 300 );
	
	///////////////////////
	// Hide/show numbers //
	///////////////////////
	
	mShowNumbers = true;
	
	TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.PicturePasswordView, 0, 0 );
	
	try
	{
		mShowNumbers = a.getBoolean( R.styleable.PicturePasswordView_showNumbers, true );
	}
	finally
	{
		a.recycle();
	}
	
	//////////////////////
	// Initialize sizes //
	//////////////////////
	mCircleSize = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 6, displayMetrics );
	mCircleSpacing = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 5, displayMetrics );
	mCirclePadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 10, displayMetrics );
}