android.view.animation.AnimationUtils#currentAnimationTimeMillis()源码实例Demo

下面列出了android.view.animation.AnimationUtils#currentAnimationTimeMillis() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: ValueAnimator.java
/**
 * Sets the position of the animation to the specified fraction. This fraction should
 * be between 0 and the total fraction of the animation, including any repetition. That is,
 * a fraction of 0 will position the animation at the beginning, a value of 1 at the end,
 * and a value of 2 at the end of a reversing animator that repeats once. If
 * the animation has not yet been started, then it will not advance forward after it is
 * set to this fraction; it will simply set the fraction to this value and perform any
 * appropriate actions based on that fraction. If the animation is already running, then
 * setCurrentFraction() will set the current fraction to this value and continue
 * playing from that point. {@link Animator.AnimatorListener} events are not called
 * due to changing the fraction; those events are only processed while the animation
 * is running.
 *
 * @param fraction The fraction to which the animation is advanced or rewound. Values
 * outside the range of 0 to the maximum fraction for the animator will be clamped to
 * the correct range.
 */
public void setCurrentFraction(float fraction) {
    initAnimation();
    fraction = clampFraction(fraction);
    mStartTimeCommitted = true; // do not allow start time to be compensated for jank
    if (isPulsingInternal()) {
        long seekTime = (long) (getScaledDuration() * fraction);
        long currentTime = AnimationUtils.currentAnimationTimeMillis();
        // Only modify the start time when the animation is running. Seek fraction will ensure
        // non-running animations skip to the correct start time.
        mStartTime = currentTime - seekTime;
    } else {
        // If the animation loop hasn't started, or during start delay, the startTime will be
        // adjusted once the delay has passed based on seek fraction.
        mSeekFraction = fraction;
    }
    mOverallFraction = fraction;
    final float currentIterationFraction = getCurrentIterationFraction(fraction, mReversing);
    animateValue(currentIterationFraction);
}
 
源代码2 项目: android_9.0.0_r45   文件: EdgeEffect.java
/**
 * Call when the object is released after being pulled.
 * This will begin the "decay" phase of the effect. After calling this method
 * the host view should {@link android.view.View#invalidate()} and thereby
 * draw the results accordingly.
 */
public void onRelease() {
    mPullDistance = 0;

    if (mState != STATE_PULL && mState != STATE_PULL_DECAY) {
        return;
    }

    mState = STATE_RECEDE;
    mGlowAlphaStart = mGlowAlpha;
    mGlowScaleYStart = mGlowScaleY;

    mGlowAlphaFinish = 0.f;
    mGlowScaleYFinish = 0.f;

    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mDuration = RECEDE_TIME;
}
 
源代码3 项目: ProjectX   文件: ScaleHelper.java
boolean computeScale() {
    if (isFinished()) {
        return false;
    }
    long time = AnimationUtils.currentAnimationTimeMillis();
    final long elapsedTime = time - mStartTime;

    final long duration = mDuration;
    if (elapsedTime < duration) {
        final float q = mInterpolator.getInterpolation(elapsedTime / (float) duration);
        mScale = mStartScale + (mTargetScale - mStartScale) * q;
    } else {
        mScale = mTargetScale;
        abortAnimation();
    }
    if (mFirst) {
        mFirst = false;
    }
    return true;
}
 
源代码4 项目: Trebuchet   文件: LauncherEdgeEffect.java
/**
 * A view should call this when content is pulled away from an edge by the user.
 * This will update the state of the current visual effect and its associated animation.
 * The host view should always {@link android.view.View#invalidate()} after this
 * and draw the results accordingly.
 *
 * @param deltaDistance Change in distance since the last call. Values may be 0 (no change) to
 *                      1.f (full length of the view) or negative values to express change
 *                      back toward the edge reached to initiate the effect.
 * @param displacement The displacement from the starting side of the effect of the point
 *                     initiating the pull. In the case of touch this is the finger position.
 *                     Values may be from 0-1.
 */
public void onPull(float deltaDistance, float displacement) {
    final long now = AnimationUtils.currentAnimationTimeMillis();
    mTargetDisplacement = displacement;
    if (mState == STATE_PULL_DECAY && now - mStartTime < mDuration) {
        return;
    }
    if (mState != STATE_PULL) {
        mGlowScaleY = Math.max(PULL_GLOW_BEGIN, mGlowScaleY);
    }
    mState = STATE_PULL;

    mStartTime = now;
    mDuration = PULL_TIME;

    mPullDistance += deltaDistance;

    final float absdd = Math.abs(deltaDistance);
    mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA,
            mGlowAlpha + (absdd * PULL_DISTANCE_ALPHA_GLOW_FACTOR));

    if (mPullDistance == 0) {
        mGlowScaleY = mGlowScaleYStart = 0;
    } else {
        final float scale = (float) (Math.max(0, 1 - 1 /
                Math.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3d) / 0.7d);

        mGlowScaleY = mGlowScaleYStart = scale;
    }

    mGlowAlphaFinish = mGlowAlpha;
    mGlowScaleYFinish = mGlowScaleY;
}
 
源代码5 项目: JNChartDemo   文件: BarLineChartTouchListener.java
public void computeScroll() {

        if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef();
        mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f;

        float distanceX = mDecelerationVelocity.x * timeInterval;
        float distanceY = mDecelerationVelocity.y * timeInterval;

        mDecelerationCurrentPoint.x += distanceX;
        mDecelerationCurrentPoint.y += distanceY;

        MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0);
        performDrag(event);
        event.recycle();
        mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else {
            // Range might have changed, which means that Y-axis labels
            // could have changed in size, affecting Y-axis size.
            // So we need to recalculate offsets.
            mChart.calculateOffsets();
            mChart.postInvalidate();

            stopDeceleration();
        }
    }
 
源代码6 项目: MiBandDecompiled   文件: ValueAnimator.java
public void setCurrentPlayTime(long l1)
{
    a();
    long l2 = AnimationUtils.currentAnimationTimeMillis();
    if (i != 1)
    {
        h = l1;
        i = 2;
    }
    g = l2 - l1;
    a(l2);
}
 
源代码7 项目: AndroidQuick   文件: TwoDScrollView.java
/**
 * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
 *
 * @param dx the number of pixels to scroll by on the X axis
 * @param dy the number of pixels to scroll by on the Y axis
 */
public final void smoothScrollBy(int dx, int dy) {
    long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
    if (duration > ANIMATED_SCROLL_GAP) {
        mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
        awakenScrollBars(mScroller.getDuration());
        invalidate();
    } else {
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        scrollBy(dx, dy);
    }
    mLastScroll = AnimationUtils.currentAnimationTimeMillis();
}
 
源代码8 项目: UltimateAndroid   文件: OutlineContainer.java
@Override
public void start() {
	if (mIsRunning)
		return;
	mIsRunning = true;
	mStartTime = AnimationUtils.currentAnimationTimeMillis();	
	post(mUpdater);
}
 
源代码9 项目: android-recipes-app   文件: AutoScrollHelper.java
/**
 * Starts the scroller at the current animation time.
 */
public void start() {
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mStopTime = -1;
    mDeltaTime = mStartTime;
    mStopValue = 0.5f;
    mDeltaX = 0;
    mDeltaY = 0;
}
 
源代码10 项目: HaoReader   文件: SwipeProgressBar.java
void start() {
    if (!this.mRunning) {
        this.mTriggerPercentage = 0.0F;
        this.mStartTime = AnimationUtils.currentAnimationTimeMillis();
        this.mRunning = true;
        ViewCompat.postInvalidateOnAnimation(this.mParent);
    }

}
 
源代码11 项目: Rey-MusicPlayer   文件: VelocityViewPager.java
private void recomputeScrollPosition(int width, int oldWidth, int margin, int oldMargin) {
    if (oldWidth > 0 && !mItems.isEmpty()) {
        final int widthWithMargin = width - getPaddingLeft() - getPaddingRight() + margin;
        final int oldWidthWithMargin = oldWidth - getPaddingLeft() - getPaddingRight()
                + oldMargin;
        final int xpos = getScrollX();
        final float pageOffset = (float) xpos / oldWidthWithMargin;
        final int newOffsetPixels = (int) (pageOffset * widthWithMargin);

        scrollTo(newOffsetPixels, getScrollY());
        if (!mScroller.isFinished()) {
            // We now return to your regularly scheduled scroll, already in progress.
            final int newDuration = Math.max(0, (int) (mScrollDuration - AnimationUtils.currentAnimationTimeMillis() - mScrollStartTime));
            ItemInfo targetInfo = infoForPosition(mCurItem);

            mScrollStartTime = AnimationUtils.currentAnimationTimeMillis();
            mScrollDuration = newDuration;
            mScroller.startScroll(newOffsetPixels, 0,
                    (int) (targetInfo.offset * width), 0, newDuration);
        }
    } else {
        final ItemInfo ii = infoForPosition(mCurItem);
        final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0;
        final int scrollPos = (int) (scrollOffset *
                (width - getPaddingLeft() - getPaddingRight()));
        if (scrollPos != getScrollX()) {
            completeScroll(false);
            scrollTo(scrollPos, getScrollY());
        }
    }
}
 
源代码12 项目: zen4android   文件: Scroller.java
/**
 * Start scrolling by providing a starting point and the distance to travel.
 * 
 * @param startX Starting horizontal scroll offset in pixels. Positive
 *        numbers will scroll the content to the left.
 * @param startY Starting vertical scroll offset in pixels. Positive numbers
 *        will scroll the content up.
 * @param dx Horizontal distance to travel. Positive numbers will scroll the
 *        content to the left.
 * @param dy Vertical distance to travel. Positive numbers will scroll the
 *        content up.
 * @param duration Duration of the scroll in milliseconds.
 */
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
    mMode = SCROLL_MODE;
    mFinished = false;
    mDuration = duration;
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mStartX = startX;
    mStartY = startY;
    mFinalX = startX + dx;
    mFinalY = startY + dy;
    mDeltaX = dx;
    mDeltaY = dy;
    mDurationReciprocal = 1.0f / (float) mDuration;
}
 
源代码13 项目: Contacts   文件: OutlineContainer.java
@Override
public void start() {
	if (mIsRunning)
		return;
	mIsRunning = true;
	mStartTime = AnimationUtils.currentAnimationTimeMillis();	
	post(mUpdater);
}
 
源代码14 项目: TiCollectionView   文件: SwipeProgressBar.java
/**
 * Start showing the progress animation.
 */
void start() {
    if (!mRunning) {
        mTriggerPercentage = 0;
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}
 
源代码15 项目: JazzyViewPager   文件: OutlineContainer.java
@Override
public void start() {
	if (mIsRunning)
		return;
	mIsRunning = true;
	mStartTime = AnimationUtils.currentAnimationTimeMillis();	
	post(mUpdater);
}
 
源代码16 项目: TiCollectionView   文件: SwipeProgressBar.java
/**
 * Stop showing the progress animation.
 */
void stop() {
    if (mRunning) {
        mTriggerPercentage = 0;
        mFinishTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = false;
        mParent.postInvalidate();
    }
}
 
源代码17 项目: JelloToggle   文件: JelloToggle.java
private void startJello() {
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    post(mJelloRunnable);
}
 
源代码18 项目: android_9.0.0_r45   文件: EdgeEffect.java
private void update() {
    final long time = AnimationUtils.currentAnimationTimeMillis();
    final float t = Math.min((time - mStartTime) / mDuration, 1.f);

    final float interp = mInterpolator.getInterpolation(t);

    mGlowAlpha = mGlowAlphaStart + (mGlowAlphaFinish - mGlowAlphaStart) * interp;
    mGlowScaleY = mGlowScaleYStart + (mGlowScaleYFinish - mGlowScaleYStart) * interp;
    mDisplacement = (mDisplacement + mTargetDisplacement) / 2;

    if (t >= 1.f - EPSILON) {
        switch (mState) {
            case STATE_ABSORB:
                mState = STATE_RECEDE;
                mStartTime = AnimationUtils.currentAnimationTimeMillis();
                mDuration = RECEDE_TIME;

                mGlowAlphaStart = mGlowAlpha;
                mGlowScaleYStart = mGlowScaleY;

                // After absorb, the glow should fade to nothing.
                mGlowAlphaFinish = 0.f;
                mGlowScaleYFinish = 0.f;
                break;
            case STATE_PULL:
                mState = STATE_PULL_DECAY;
                mStartTime = AnimationUtils.currentAnimationTimeMillis();
                mDuration = PULL_DECAY_TIME;

                mGlowAlphaStart = mGlowAlpha;
                mGlowScaleYStart = mGlowScaleY;

                // After pull, the glow should fade to nothing.
                mGlowAlphaFinish = 0.f;
                mGlowScaleYFinish = 0.f;
                break;
            case STATE_PULL_DECAY:
                mState = STATE_RECEDE;
                break;
            case STATE_RECEDE:
                mState = STATE_IDLE;
                break;
        }
    }
}
 
源代码19 项目: TurboLauncher   文件: LauncherScroller.java
/**
 * Returns the time elapsed since the beginning of the scrolling.
 *
 * @return The elapsed time in milliseconds.
 */
public int timePassed() {
    return (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
}
 
源代码20 项目: UltimateAndroid   文件: Scroller.java
/**
 * Returns the time elapsed since the beginning of the scrolling.
 *
 * @return The elapsed time in milliseconds.
 */
public int timePassed() {
    return (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
}