Example usage for android.view.animation AnimationUtils currentAnimationTimeMillis

List of usage examples for android.view.animation AnimationUtils currentAnimationTimeMillis

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils currentAnimationTimeMillis.

Prototype

public static long currentAnimationTimeMillis() 

Source Link

Document

Returns the current animation time in milliseconds.

Usage

From source file:de.telekom.pde.codelibrary.ui.layout.PDESwipeRefreshLayout.java

@Override
public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);

    int width = mBounds.width();
    int height = mBounds.height();
    int cx = width / 2;
    int cy = height / 2;

    int restoreCount = canvas.save();
    canvas.clipRect(mBounds);// ww  w.  j av  a  2 s  .c  om

    if (mRunning) {
        long now = AnimationUtils.currentAnimationTimeMillis();
        long elapsed = (now - mStartTime) % mAnimationDuration;
        float currentAngle = (elapsed / (mAnimationDuration / 100f)) * 3.6f;

        canvas.drawCircle(cx, cy, PDEBuildingUnits.BU(), mPaint);

        canvas.save();
        canvas.rotate(currentAngle, cx, cy);
        canvas.drawPath(mCirclePath, mWhitePaint);
        canvas.restore();

        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        // Otherwise if we're in the middle of a trigger, draw that.
        if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
            drawTrigger(canvas, cx, cy);
        }
    }
    canvas.restoreToCount(restoreCount);
}

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation,
        float ratio, float anchor, int source) {
    bm = filter(iv, bm, fallback);//from  www  . j a v  a 2s.c o m
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }
    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;
    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {
            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }
    iv.setImageDrawable(d);
    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation,
        float ratio, float anchor, int source) {

    bm = filter(iv, bm, fallback);//ww  w . j  a  v a2  s .co m
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }

    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;

    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {

            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }

    iv.setImageDrawable(d);

    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void touchBegan(MotionEvent event) {
    endAnimation();/*from w  w w.  j av a2s . com*/

    float x = event.getX();
    mTouchStartX = x;
    mTouchStartY = event.getY();
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mStartOffset = mOffset;

    mTouchMoved = false;

    mTouchStartPos = (x / mWidth) * MOVE_POS_MULTIPLE - 5;
    mTouchStartPos /= 2;

    mVelocity = VelocityTracker.obtain();
    mVelocity.addMovement(event);
}

From source file:com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.java

/**
 * Sets the position of the animation to the specified point in time. This time should
 * be between 0 and the total duration of the animation, including any repetition. If
 * the animation has not yet been started, then it will not advance forward after it is
 * set to this time; it will simply set the time to this value and perform any appropriate
 * actions based on that time. If the animation is already running, then setCurrentPlayTime()
 * will set the current playing time to this value and continue playing from that point.
 *
 * @param playTime The time, in milliseconds, to which the animation is advanced or rewound.
 */// ww w.j a  v a 2s . co m
public void setCurrentPlayTime(long playTime) {
    initAnimation();
    long currentTime = AnimationUtils.currentAnimationTimeMillis();
    if (mPlayingState != RUNNING) {
        mSeekTime = playTime;
        mPlayingState = SEEKED;
    }
    mStartTime = currentTime - playTime;
    animationFrame(currentTime);
}

From source file:com.abslyon.abetterselection.CoverFlow.CoverFlowView.java

private void startAnimation(double speed) {
    if (mAnimationRunnable != null) {
        return;//from   ww  w.  j  a  v a 2  s.  c  o m
    }

    double delta = speed * speed / (FRICTION * 2);
    if (speed < 0) {
        delta = -delta;
    }

    double nearest = mStartOffset + delta;
    nearest = Math.floor(nearest + 0.5);

    mStartSpeed = (float) Math.sqrt(Math.abs(nearest - mStartOffset) * FRICTION * 2);
    if (nearest < mStartOffset) {
        mStartSpeed = -mStartSpeed;
    }

    mDuration = Math.abs(mStartSpeed / FRICTION);
    mStartTime = AnimationUtils.currentAnimationTimeMillis();

    mAnimationRunnable = new Runnable() {
        @Override
        public void run() {
            driveAnimation();
        }
    };
    post(mAnimationRunnable);
}

From source file:com.dolphinwang.imagecoverflow.CoverFlowView.java

private void touchBegan(MotionEvent event) {
    endAnimation();/*from   ww w .  ja va  2 s . c o m*/

    float x = event.getX();
    mTouchStartX = x;
    mTouchStartY = event.getY();
    mStartTime = AnimationUtils.currentAnimationTimeMillis();

    mStartOffset = mOffset;

    mTouchMoved = false;
    mTouchStartPos = (x / mWidth) * MOVE_POS_MULTIPLE - 5;
    mTouchStartPos /= 2;

    mVelocity = VelocityTracker.obtain();
    mVelocity.addMovement(event);
}

From source file:com.abslyon.abetterselection.CoverFlow.CoverFlowView.java

private void driveAnimation() {
    float elapsed = (AnimationUtils.currentAnimationTimeMillis() - mStartTime) / 1000.0f;
    if (elapsed >= mDuration) {
        endAnimation();/*from ww w . ja va 2 s  .  co m*/
    } else {
        updateAnimationAtElapsed(elapsed);
        post(mAnimationRunnable);
    }
}

From source file:com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.java

/**
 * Gets the current position of the animation in time, which is equal to the current
 * time minus the time that the animation started. An animation that is not yet started will
 * return a value of zero.//w  ww  . jav a  2s . com
 *
 * @return The current position in time of the animation.
 */
public long getCurrentPlayTime() {
    if (!mInitialized || mPlayingState == STOPPED) {
        return 0;
    }
    return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void startAnimation(double speed) {
    if (mAnimationRunnable != null)
        return;//from ww  w .  j  a  va 2  s  . co m

    double delta = speed * speed / (FRICTION * 2);
    if (speed < 0)
        delta = -delta;

    double nearest = mStartOffset + delta;
    nearest = Math.floor(nearest + 0.5);

    mStartSpeed = (float) Math.sqrt(Math.abs(nearest - mStartOffset) * FRICTION * 2);
    if (nearest < mStartOffset)
        mStartSpeed = -mStartSpeed;

    mDuration = Math.abs(mStartSpeed / FRICTION);
    mStartTime = AnimationUtils.currentAnimationTimeMillis();

    mAnimationRunnable = new Runnable() {
        @Override
        public void run() {
            driveAnimation();
        }
    };
    post(mAnimationRunnable);
}