Java Code Examples for android.animation.ValueAnimator#AnimatorUpdateListener

The following examples show how to use android.animation.ValueAnimator#AnimatorUpdateListener . 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: ValueAnimatorUpdateListenerOnSubscribe.java    From RxAnimationBinding with Apache License 2.0 6 votes vote down vote up
@Override
public void call(final Subscriber<? super ValueAnimator> subscriber) {

    final ValueAnimator.AnimatorUpdateListener listener = new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            if (!subscriber.isUnsubscribed()) {
                subscriber.onNext(animator);
            }
        }
    };

    animator.addUpdateListener(listener);

    subscriber.add(new OnUnsubscribedCallback() {
        @Override
        protected void onUnsubscribe() {
            animator.removeUpdateListener(listener);
        }
    });
}
 
Example 2
Source File: LocationAnimator.java    From BLE-Indoor-Positioning with Apache License 2.0 6 votes vote down vote up
private ValueAnimator.AnimatorUpdateListener createAnimatorUpdateListener() {
    return new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float value = (float) valueAnimator.getAnimatedValue();
            if (valueAnimator == latitudeAnimator) {
                currentLocation.setLatitude(originLocation.getLatitude() + (latitudeDelta * value));
            } else if (valueAnimator == longitudeAnimator) {
                currentLocation.setLongitude(originLocation.getLongitude() + (longitudeDelta * value));
            } else if (valueAnimator == accuracyAnimator) {
                currentLocation.setAccuracy(originLocation.getAccuracy() + (accuracyDelta * value));
            }
            onCurrentLocationUpdated();
        }
    };
}
 
Example 3
Source File: BaseChart.java    From JZAndroidChart with Apache License 2.0 6 votes vote down vote up
@Override
public void initChart() {

    mAxisRenderers = new ArrayList<>(4);

    mAxisRenderers.add(new AxisRenderer(this, mAxisTop));
    mAxisRenderers.add(new AxisRenderer(this, mAxisBottom));
    mAxisRenderers.add(new AxisRenderer(this, mAxisLeft));
    mAxisRenderers.add(new AxisRenderer(this, mAxisRight));

    mChartAnimator = new ChartAnimator(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
}
 
Example 4
Source File: RefreshContentHorizontal.java    From SmartRefreshHorizontal with Apache License 2.0 5 votes vote down vote up
@Override
public ValueAnimator.AnimatorUpdateListener scrollContentWhenFinished(final int spinner) {
    if (mScrollableView != null && spinner != 0) {
        if ((spinner < 0 && ScrollBoundaryHorizontal.canScrollRight(mScrollableView)) || (spinner > 0 && ScrollBoundaryHorizontal.canScrollLeft(mScrollableView))) {
            mLastSpinner = spinner;
            return this;
        }
    }
    return null;
}
 
Example 5
Source File: BaseChartView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
ValueAnimator createAnimator(float f1, float f2, ValueAnimator.AnimatorUpdateListener l) {
    ValueAnimator a = ValueAnimator.ofFloat(f1, f2);
    a.setDuration(ANIM_DURATION);
    a.setInterpolator(INTERPOLATOR);
    a.addUpdateListener(l);
    return a;
}
 
Example 6
Source File: AnimationProcessor.java    From SlideUp-Android with MIT License 5 votes vote down vote up
private void createAnimation(ValueAnimator.AnimatorUpdateListener updateListener, Animator.AnimatorListener listener){
    mValueAnimator = ValueAnimator.ofFloat();
    mValueAnimator.setDuration(mBuilder.mAutoSlideDuration);
    mValueAnimator.setInterpolator(mBuilder.mInterpolator);
    mValueAnimator.addUpdateListener(updateListener);
    mValueAnimator.addListener(listener);
}
 
Example 7
Source File: AnimatedDrawableValueAnimatorHelper.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Create an animator update listener to be used to update the drawable to be animated.
 *
 * @param drawable the drawable to create the animator update listener for
 * @return the listener to use
 */
@Nullable
public static ValueAnimator.AnimatorUpdateListener createAnimatorUpdateListener(
    final Drawable drawable) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
    return null;
  }

  if (drawable instanceof AnimatedDrawable2) {
    return AnimatedDrawable2ValueAnimatorHelper.createAnimatorUpdateListener(
        (AnimatedDrawable2) drawable);
  }
  return null;
}
 
Example 8
Source File: RxAnimator.java    From RxAnimator with Apache License 2.0 5 votes vote down vote up
public RxAnimatorObservable animationAddUpdateListener(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
    if (this.animatorUpdateListeners == null) {
        this.animatorUpdateListeners = new ArrayList<>();
    }
    this.animatorUpdateListeners.add(animatorUpdateListener);
    return this;
}
 
Example 9
Source File: ViewPropertyAnimator.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
ValueAnimator.AnimatorUpdateListener getUpdateListener() {
    return mUpdateListener;
}
 
Example 10
Source File: LottieAnimationView.java    From atlas with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
public void removeUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener) {
  lottieDrawable.removeAnimatorUpdateListener(updateListener);
}
 
Example 11
Source File: BaseAdditiveAnimator.java    From android_additive_animations with Apache License 2.0 4 votes vote down vote up
public T addUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
    getValueAnimator().addUpdateListener(listener);
    return self();
}
 
Example 12
Source File: LottieDrawable.java    From atlas with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("WeakerAccess") public void removeAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener) {
  animator.removeUpdateListener(updateListener);
}
 
Example 13
Source File: LottieDrawable.java    From atlas with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("WeakerAccess") public void addAnimatorUpdateListener(ValueAnimator.AnimatorUpdateListener updateListener) {
  animator.addUpdateListener(updateListener);
}
 
Example 14
Source File: ArcProgressStackView.java    From ArcProgressStackView with Apache License 2.0 4 votes vote down vote up
public void setAnimatorUpdateListener(final ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
    mAnimatorUpdateListener = animatorUpdateListener;
}
 
Example 15
Source File: BaseLottieAnimator.java    From lottie-android with Apache License 2.0 4 votes vote down vote up
void notifyUpdate() {
  for (ValueAnimator.AnimatorUpdateListener listener : updateListeners) {
    listener.onAnimationUpdate(this);
  }
}
 
Example 16
Source File: CaptureAnimationOverlay.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
public CaptureAnimationOverlay(Context context, AttributeSet attrs)
{
    super(context, attrs);
    mPaint.setColor(FLASH_COLOR);
    mFlashAnimInterpolator = new LinearInterpolator();
    mFlashAnimUpdateListener = new ValueAnimator.AnimatorUpdateListener()
    {
        @Override
        public void onAnimationUpdate(ValueAnimator animation)
        {
            float alpha = 255.0f * (Float) animation.getAnimatedValue();
            mPaint.setAlpha((int) alpha);
            invalidate();
        }
    };
    mFlashAnimListener = new Animator.AnimatorListener()
    {
        @Override
        public void onAnimationStart(Animator animation)
        {
            setVisibility(VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation)
        {
            mFlashAnimation = null;
            setVisibility(INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation)
        {
            // End is always called after cancel.
        }

        @Override
        public void onAnimationRepeat(Animator animation)
        {

        }
    };
}
 
Example 17
Source File: ViewPropertyObjectAnimator.java    From ViewPropertyObjectAnimator with Apache License 2.0 4 votes vote down vote up
public ViewPropertyObjectAnimator removeUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
    mUpdateListeners.remove(listener);
    return this;
}
 
Example 18
Source File: SmartSelectSprite.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private Animator createAnimator(
        final RectangleList rectangleList,
        final float startingOffsetLeft,
        final float startingOffsetRight,
        final List<Animator> cornerAnimators,
        final ValueAnimator.AnimatorUpdateListener updateListener,
        final Runnable onAnimationEnd) {
    final ObjectAnimator rightBoundaryAnimator = ObjectAnimator.ofFloat(
            rectangleList,
            RectangleList.PROPERTY_RIGHT_BOUNDARY,
            startingOffsetRight,
            rectangleList.getTotalWidth());

    final ObjectAnimator leftBoundaryAnimator = ObjectAnimator.ofFloat(
            rectangleList,
            RectangleList.PROPERTY_LEFT_BOUNDARY,
            startingOffsetLeft,
            0);

    rightBoundaryAnimator.setDuration(EXPAND_DURATION);
    leftBoundaryAnimator.setDuration(EXPAND_DURATION);

    rightBoundaryAnimator.addUpdateListener(updateListener);
    leftBoundaryAnimator.addUpdateListener(updateListener);

    rightBoundaryAnimator.setInterpolator(mExpandInterpolator);
    leftBoundaryAnimator.setInterpolator(mExpandInterpolator);

    final AnimatorSet cornerAnimator = new AnimatorSet();
    cornerAnimator.playTogether(cornerAnimators);

    final AnimatorSet boundaryAnimator = new AnimatorSet();
    boundaryAnimator.playTogether(leftBoundaryAnimator, rightBoundaryAnimator);

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(boundaryAnimator, cornerAnimator);

    setUpAnimatorListener(animatorSet, onAnimationEnd);

    return animatorSet;
}
 
Example 19
Source File: Indicator.java    From XKnife-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Your should use this to add AnimatorUpdateListener when
 * create animator , otherwise , animator doesn't work when
 * the animation restart .
 *
 * @param updateListener
 */
public void addUpdateListener(ValueAnimator animator, ValueAnimator.AnimatorUpdateListener updateListener) {
    mUpdateListeners.put(animator, updateListener);
}
 
Example 20
Source File: TouchCircleDrawable.java    From Camera2 with Apache License 2.0 2 votes vote down vote up
/**
 * Set an {@link android.animation.ValueAnimator} to be
 * attached to the animation.
 *
 * @param listener The listener.
 */
public void setUpdateListener(ValueAnimator.AnimatorUpdateListener listener)
{
    mUpdateListener = listener;
}