Java Code Examples for android.animation.TimeAnimator#setTimeListener()

The following examples show how to use android.animation.TimeAnimator#setTimeListener() . 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: GenericTouchGesture.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Runnable createJBRunnable() {
    // On JB, we rely on TimeAnimator to send events tied with vsync.
    return new Runnable() {
        @Override
        public void run() {
            mTimeAnimator = new TimeAnimator();
            mTimeAnimator.setTimeListener(new TimeListener() {
                @Override
                public void onTimeUpdate(TimeAnimator animation, long totalTime,
                        long deltaTime) {
                    if (!sendEvent(mStartTime + totalTime)) {
                        mTimeAnimator.end();
                    }
                }
            });
            mTimeAnimator.start();
        }
    };
}
 
Example 2
Source File: GenericTouchGesture.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Runnable createJBRunnable() {
    // On JB, we rely on TimeAnimator to send events tied with vsync.
    return new Runnable() {
        @Override
        public void run() {
            mTimeAnimator = new TimeAnimator();
            mTimeAnimator.setTimeListener(new TimeListener() {
                @Override
                public void onTimeUpdate(TimeAnimator animation, long totalTime,
                        long deltaTime) {
                    if (!sendEvent(mStartTime + totalTime)) {
                        mTimeAnimator.end();
                    }
                }
            });
            mTimeAnimator.start();
        }
    };
}
 
Example 3
Source File: ContinuousExampleComponentSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
private static Animator createRotationAnimator(final DynamicValue<Float> rotation) {
  final TimeAnimator animator = new TimeAnimator();
  final FloatEvaluator floatEvaluator = new FloatEvaluator();
  animator.setTimeListener(
      new TimeAnimator.TimeListener() {
        @Override
        public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
          float fraction =
              Float.valueOf(totalTime % ANIMATION_DURATION_MS) / ANIMATION_DURATION_MS;
          rotation.set(fraction * 360);
        }
      });
  return animator;
}
 
Example 4
Source File: BugView.java    From Bugstick with MIT License 5 votes vote down vote up
private void init(Context context) {
    animator = new TimeAnimator();
    animator.setTimeListener(this);

    paint = new Paint();
    paint.setColor(Color.WHITE);

    density = getResources().getDisplayMetrics().density;

    path = new Path();
    pathMeasure = new PathMeasure();
    position = new PointF();
    velocity = new PointF();
}
 
Example 5
Source File: PropertyAnimation09.java    From cogitolearning-examples with MIT License 5 votes vote down vote up
@Override
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.property_animations09);

  if (android.os.Build.VERSION.SDK_INT >= 19)
  {
    ImageView someImage = (ImageView) findViewById(R.id.some_image);

    ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(someImage, "rotation", 0, 360);
    rotateAnim.setDuration(1000);
    rotateAnim.setRepeatCount(5);
    rotateAnim.setRepeatMode(ObjectAnimator.RESTART);

    fpsText = (TextView) findViewById(R.id.fps_text);
    FpsTimeListener listener = new FpsTimeListener(fpsText);
    
    final TimeAnimator timeAnim = new TimeAnimator();
    timeAnim.setTimeListener(listener);
    
    anim = new AnimatorSet();
    anim.play(rotateAnim).with(timeAnim);
    rotateAnim.addListener(new AnimatorListenerAdapter()
    {
      @Override
      public void onAnimationEnd(Animator animation)
      {
        timeAnim.end(); 
      }
    });
  }
}
 
Example 6
Source File: XDripDreamService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Bouncer(Context context, AttributeSet attrs, int flags) {
    super(context, attrs, flags);
    mAnimator = new TimeAnimator();
    mAnimator.setTimeListener(this);
}
 
Example 7
Source File: XDripDreamService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public Bouncer(Context context, AttributeSet attrs, int flags) {
    super(context, attrs, flags);
    mAnimator = new TimeAnimator();
    mAnimator.setTimeListener(this);
}
 
Example 8
Source File: Bouncer.java    From androidtv-daydream with Apache License 2.0 4 votes vote down vote up
public Bouncer(Context context, AttributeSet attrs, int flags) {
    super(context, attrs, flags);
    mAnimator = new TimeAnimator();
    mAnimator.setTimeListener(this);
}