当前位置: 首页>>代码示例>>Java>>正文


Java AnimationUtils.currentAnimationTimeMillis方法代码示例

本文整理汇总了Java中android.view.animation.AnimationUtils.currentAnimationTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java AnimationUtils.currentAnimationTimeMillis方法的具体用法?Java AnimationUtils.currentAnimationTimeMillis怎么用?Java AnimationUtils.currentAnimationTimeMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.animation.AnimationUtils的用法示例。


在下文中一共展示了AnimationUtils.currentAnimationTimeMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onAbsorb

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Call when the effect absorbs an impact at the given velocity.
 * Used when a fling reaches the scroll boundary.
 *
 * <p>When using a {@link android.widget.Scroller} or {@link android.widget.OverScroller},
 * the method <code>getCurrVelocity</code> will provide a reasonable approximation
 * to use here.</p>
 *
 * @param velocity Velocity at impact in pixels per second.
 */
public void onAbsorb(int velocity) {
    mState = STATE_ABSORB;
    velocity = Math.min(Math.max(MIN_VELOCITY, Math.abs(velocity)), MAX_VELOCITY);

    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mDuration = 0.15f + (velocity * 0.02f);

    // The glow depends more on the velocity, and therefore starts out
    // nearly invisible.
    mGlowAlphaStart = 0.3f;
    mGlowScaleYStart = Math.max(mGlowScaleY, 0.f);


    // Growth for the size of the glow should be quadratic to properly
    // respond
    // to a user's scrolling speed. The faster the scrolling speed, the more
    // intense the effect should be for both the size and the saturation.
    mGlowScaleYFinish = Math.min(0.025f + (velocity * (velocity / 100) * 0.00015f) / 2, 1.f);
    // Alpha should change for the glow as well as size.
    mGlowAlphaFinish = Math.max(
            mGlowAlphaStart, Math.min(velocity * VELOCITY_GLOW_FACTOR * .00001f, MAX_ALPHA));
    mTargetDisplacement = 0.5f;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:34,代码来源:LauncherEdgeEffect.java

示例2: run

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
@Override
public void run() {
    if (mScrollDir == 0)
        return;

    long now = AnimationUtils.currentAnimationTimeMillis();
    float delta = (now - mPrevTime) * 0.001f;
    mPrevTime = now;

    mRecyclerView.scrollBy(0, (int) (delta * mAutoscrollAmount * mScrollDir));
    LinearLayoutManager llm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
    updateHightlightedElements(mRecyclerView, mScrollDir > 0
            ? llm.findLastCompletelyVisibleItemPosition()
            : llm.findFirstCompletelyVisibleItemPosition());
    ViewCompat.postOnAnimation(mRecyclerView, this);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:17,代码来源:LongPressSelectTouchListener.java

示例3: start

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
@Override
public void start() {
	if (mIsRunning)
		return;
	mIsRunning = true;
	mStartTime = AnimationUtils.currentAnimationTimeMillis();	
	post(mUpdater);
}
 
开发者ID:hishamMuneer,项目名称:JazzyViewPager,代码行数:9,代码来源:OutlineContainer.java

示例4: setScrollDir

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
public void setScrollDir(int dir) {
    if (mScrollDir == dir)
        return;
    if (dir != 0 && mScrollDir == 0)
        ViewCompat.postOnAnimation(mRecyclerView, this);
    mScrollDir = dir;
    mPrevTime = AnimationUtils.currentAnimationTimeMillis();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:9,代码来源:LongPressSelectTouchListener.java

示例5: reverse

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Plays the ValueAnimator in reverse. If the animation is already running,
 * it will stop itself and play backwards from the point reached when reverse was called.
 * If the animation is not currently running, then it will start from the end and
 * play backwards. This behavior is only set for the current animation; future playing
 * of the animation will use the default behavior of playing forward.
 */
public void reverse() {
    mPlayingBackwards = !mPlayingBackwards;
    if (mPlayingState == RUNNING) {
        long currentTime = AnimationUtils.currentAnimationTimeMillis();
        long currentPlayTime = currentTime - mStartTime;
        long timeLeft = mDuration - currentPlayTime;
        mStartTime = currentTime - timeLeft;
    } else {
        start(true);
    }
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:19,代码来源:ValueAnimator.java

示例6: fling

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
void fling(int start, int velocity, int min, int max, int over) {
    mOver = over;
    mFinished = false;
    mCurrVelocity = mVelocity = velocity;
    mDuration = mSplineDuration = 0;
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mCurrentPosition = mStart = start;

    if (start > max || start < min) {
        startAfterEdge(start, min, max, velocity);
        return;
    }

    mState = SPLINE;
    double totalDistance = 0.0;

    if (velocity != 0) {
        mDuration = mSplineDuration = getSplineFlingDuration(velocity);
        totalDistance = getSplineFlingDistance(velocity);
    }

    mSplineDistance = (int) (totalDistance * Math.signum(velocity));
    mFinal = start + mSplineDistance;

    // Clamp to a valid final position
    if (mFinal < min) {
        adjustDuration(mStart, mFinal, min);
        mFinal = min;
    }

    if (mFinal > max) {
        adjustDuration(mStart, mFinal, max);
        mFinal = max;
    }
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:36,代码来源:VelocityScroller.java

示例7: startScroll

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
void startScroll(int start, int distance, int duration) {
    mFinished = false;

    mStart = start;
    mFinal = start + distance;

    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mDuration = duration;

    // Unused
    mDeceleration = 0.0f;
    mVelocity = 0;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:14,代码来源:OverScroller.java

示例8: startScroll

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:27,代码来源:Scroller.java

示例9: onTouch

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {

    if (mGestureDetector.onTouchEvent(event))
        return true;

    // if rotation by touch is enabled
    if (mChart.isRotationEnabled()) {

        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:

                startAction(event);

                stopDeceleration();

                resetVelocity();

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                setGestureStartAngle(x, y);
                mTouchStartPoint.x = x;
                mTouchStartPoint.y = y;

                break;
            case MotionEvent.ACTION_MOVE:

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                if (mTouchMode == NONE
                        && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y)
                        > Utils.convertDpToPixel(8f)) {
                    mLastGesture = ChartGesture.ROTATE;
                    mTouchMode = ROTATE;
                    mChart.disableScroll();
                } else if (mTouchMode == ROTATE) {
                    updateGestureRotation(x, y);
                    mChart.invalidate();
                }

                endAction(event);

                break;
            case MotionEvent.ACTION_UP:

                if (mChart.isDragDecelerationEnabled()) {

                    stopDeceleration();

                    sampleVelocity(x, y);

                    mDecelerationAngularVelocity = calculateVelocity();

                    if (mDecelerationAngularVelocity != 0.f) {
                        mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis();

                        Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
                    }
                }

                mChart.enableScroll();
                mTouchMode = NONE;

                endAction(event);

                break;
        }
    }

    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:PieRadarChartTouchListener.java

示例10: computeScrollOffset

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Call this when you want to know the new location.  If it returns true,
 * the animation is not yet finished.  loc will be altered to provide the
 * new location.
 */
public boolean computeScrollOffset() {
    if (mFinished) {
        return false;
    }

    int timePassed = (int) (AnimationUtils.currentAnimationTimeMillis() - mStartTime);

    if (timePassed < mDuration) {
        switch (mMode) {
        case SCROLL_MODE:
            float x = timePassed * mDurationReciprocal;

            if (mInterpolator == null)
                x = viscousFluid(x);
            else
                x = mInterpolator.getInterpolation(x);

            mCurrX = mStartX + Math.round(x * mDeltaX);
            mCurrY = mStartY + Math.round(x * mDeltaY);
            break;
        case FLING_MODE:
            final float t = (float) timePassed / mDuration;
            final int index = (int) (NB_SAMPLES * t);
            final float tInf = (float) index / NB_SAMPLES;
            final float tSup = (float) (index + 1) / NB_SAMPLES;
            final float dInf = SPLINE[index];
            final float dSup = SPLINE[index + 1];
            final float distanceCoef = dInf + (t - tInf) / (tSup - tInf) * (dSup - dInf);

            mCurrX = mStartX + Math.round(distanceCoef * (mFinalX - mStartX));
            // Pin to mMinX <= mCurrX <= mMaxX
            mCurrX = Math.min(mCurrX, mMaxX);
            mCurrX = Math.max(mCurrX, mMinX);

            mCurrY = mStartY + Math.round(distanceCoef * (mFinalY - mStartY));
            // Pin to mMinY <= mCurrY <= mMaxY
            mCurrY = Math.min(mCurrY, mMaxY);
            mCurrY = Math.max(mCurrY, mMinY);

            if (mCurrX == mFinalX && mCurrY == mFinalY) {
                mFinished = true;
            }

            break;
        }
    } else {
        mCurrX = mFinalX;
        mCurrY = mFinalY;
        mFinished = true;
    }
    return true;
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:58,代码来源:Scroller.java

示例11: computeScroll

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
@Override
public void computeScroll() {
    int lastCurY = mScroller.getCurrY();
    if (mScroller.computeScrollOffset()) {
        int finay = mScroller.getFinalY();
        if ((finay > 0 && mRefreshContent.canLoadmore())
                || (finay < 0 && mRefreshContent.canRefresh())) {
            if(mVerticalPermit) {
                int velocity;
                if (Build.VERSION.SDK_INT >= 14) {
                    velocity = (int) mScroller.getCurrVelocity();
                } else {
                    velocity = (finay - mScroller.getCurrY()) / (mScroller.getDuration() - mScroller.timePassed());
                }
                long lastTime = AnimationUtils.currentAnimationTimeMillis() - 1000 * Math.abs(mScroller.getCurrY() - lastCurY) / velocity;
                if (finay > 0) {// 手势向上划 Footer
                    if (isEnableLoadmore() || mEnableOverScrollDrag) {
                        if (mEnableAutoLoadmore && isEnableLoadmore() && !mLoadmoreFinished) {
                            animSpinnerBounce(-(int) (mFooterHeight * Math.pow(1.0 * velocity / mMaximumVelocity, 0.5)));
                            if (!mState.opening && mState != RefreshState.Loading && mState != RefreshState.LoadFinish) {
                                setStateDirectLoading();
                            }
                        } else if (mEnableOverScrollBounce) {
                            animSpinnerBounce(-(int) (mFooterHeight * Math.pow(1.0 * velocity / mMaximumVelocity, 0.5)));
                        }
                    }
                } else {// 手势向下划 Header
                    if (isEnableRefresh() || mEnableOverScrollDrag) {
                        if (mEnableOverScrollBounce) {
                            animSpinnerBounce((int) (mHeaderHeight * Math.pow(1.0 * velocity / mMaximumVelocity, 0.5)));
                        }
                    }
                }
                mVerticalPermit = false;//关闭竖直通行证
            }
            mScroller.forceFinished(true);
        } else {
            mVerticalPermit = true;//打开竖直通行证
            invalidate();
        }
    }
}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:43,代码来源:SmartRefreshLayout.java

示例12: computeScrollOffset

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Call this when you want to know the new location. If it returns true, the
 * animation is not yet finished.
 */
public boolean computeScrollOffset() {
    if (isFinished()) {
        return false;
    }

    switch (mMode) {
        case SCROLL_MODE:
            long time = AnimationUtils.currentAnimationTimeMillis();
            // Any scroller can be used for time, since they were started
            // together in scroll mode. We use X here.
            final long elapsedTime = time - mScrollerX.mStartTime;

            final int duration = mScrollerX.mDuration;
            if (elapsedTime < duration) {
                float q = (float) (elapsedTime) / duration;

                if (mInterpolator == null) {
                    q = ScrollerUtil.viscousFluid(q);
                } else {
                    q = mInterpolator.getInterpolation(q);
                }

                mScrollerX.updateScroll(q);
                mScrollerY.updateScroll(q);
            } else {
                abortAnimation();
            }
            break;

        case FLING_MODE:
            if (!mScrollerX.mFinished) {
                if (!mScrollerX.update()) {
                    if (!mScrollerX.continueWhenFinished()) {
                        mScrollerX.finish();
                    }
                }
            }

            if (!mScrollerY.mFinished) {
                if (!mScrollerY.update()) {
                    if (!mScrollerY.continueWhenFinished()) {
                        mScrollerY.finish();
                    }
                }
            }

            break;
    }
    return true;
}
 
开发者ID:anmingyu11,项目名称:OverScrollableRecyclerView-Method1,代码行数:55,代码来源:AScroller.java

示例13: extendDuration

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
void extendDuration(int extend) {
    final long time = AnimationUtils.currentAnimationTimeMillis();
    final int elapsedTime = (int) (time - mStartTime);
    mDuration = elapsedTime + extend;
    mFinished = false;
}
 
开发者ID:anmingyu11,项目名称:OverScrollableRecyclerView-Method1,代码行数:7,代码来源:AScroller.java

示例14: fling

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Start scrolling based on a fling gesture. The distance travelled will
 * depend on the initial velocity of the fling.
 * 
 * @param startX Starting point of the scroll (X)
 * @param startY Starting point of the scroll (Y)
 * @param velocityX Initial velocity of the fling (X) measured in pixels per
 *        second.
 * @param velocityY Initial velocity of the fling (Y) measured in pixels per
 *        second
 * @param minX Minimum X value. The scroller will not scroll past this
 *        point.
 * @param maxX Maximum X value. The scroller will not scroll past this
 *        point.
 * @param minY Minimum Y value. The scroller will not scroll past this
 *        point.
 * @param maxY Maximum Y value. The scroller will not scroll past this
 *        point.
 */
public void fling(int startX, int startY, int velocityX, int velocityY,
        int minX, int maxX, int minY, int maxY) {
    // Continue a scroll or fling in progress
    if (mFlywheel && !mFinished) {
        float oldVel = getCurrVelocity();

        float dx = (float) (mFinalX - mStartX);
        float dy = (float) (mFinalY - mStartY);
        float hyp = (float)Math.sqrt(dx * dx + dy * dy);

        float ndx = dx / hyp;
        float ndy = dy / hyp;

        float oldVelocityX = ndx * oldVel;
        float oldVelocityY = ndy * oldVel;
        if (Math.signum(velocityX) == Math.signum(oldVelocityX) &&
                Math.signum(velocityY) == Math.signum(oldVelocityY)) {
            velocityX += oldVelocityX;
            velocityY += oldVelocityY;
        }
    }

    mMode = FLING_MODE;
    mFinished = false;

    float velocity = (float)Math.sqrt(velocityX * velocityX + velocityY * velocityY);
 
    mVelocity = velocity;
    final double l = Math.log(START_TENSION * velocity / ALPHA);
    mDuration = (int) (1000.0 * Math.exp(l / (DECELERATION_RATE - 1.0)));
    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mStartX = startX;
    mStartY = startY;

    float coeffX = velocity == 0 ? 1.0f : velocityX / velocity;
    float coeffY = velocity == 0 ? 1.0f : velocityY / velocity;

    int totalDistance =
            (int) (ALPHA * Math.exp(DECELERATION_RATE / (DECELERATION_RATE - 1.0) * l));
    
    mMinX = minX;
    mMaxX = maxX;
    mMinY = minY;
    mMaxY = maxY;

    mFinalX = startX + Math.round(totalDistance * coeffX);
    // Pin to mMinX <= mFinalX <= mMaxX
    mFinalX = Math.min(mFinalX, mMaxX);
    mFinalX = Math.max(mFinalX, mMinX);
    
    mFinalY = startY + Math.round(totalDistance * coeffY);
    // Pin to mMinY <= mFinalY <= mMaxY
    mFinalY = Math.min(mFinalY, mMaxY);
    mFinalY = Math.max(mFinalY, mMinY);
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:75,代码来源:Scroller.java

示例15: startScroll

import android.view.animation.AnimationUtils; //导入方法依赖的package包/类
/**
 * Start scrolling by providing a starting point, the distance to travel,
 * and the duration of the scroll.
 *
 * @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;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:28,代码来源:LauncherScroller.java


注:本文中的android.view.animation.AnimationUtils.currentAnimationTimeMillis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。