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:org.mozilla.gecko.animation.PropertyAnimator.java

public long getRemainingTime() {
    int timePassed = (int) (AnimationUtils.currentAnimationTimeMillis() - mStartTime);
    return mDuration - timePassed;
}

From source file:org.mozilla.gecko.animation.PropertyAnimator.java

@Override
public void run() {
    int timePassed = (int) (AnimationUtils.currentAnimationTimeMillis() - mStartTime);
    if (timePassed >= mDuration) {
        stop();//from   www . j ava  2 s  .  c om
        return;
    }

    float interpolation = mInterpolator.getInterpolation(timePassed * mDurationReciprocal);

    for (ElementHolder element : mElementsList) {
        float delta = element.from + ((element.to - element.from) * interpolation);
        invalidate(element, delta);
    }

    mFramePoster.postNextAnimationFrame();
}

From source file:com.gelakinetic.mtgfam.helpers.IndeterminateProgressBar.java

/**
 * Start showing the progress animation.
 *//*from  www  .j a v  a2s .c o  m*/
public void start() {
    if (!mRunning) {
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}

From source file:com.gelakinetic.mtgfam.helpers.IndeterminateProgressBar.java

/**
 * Stop showing the progress animation.//from   ww  w  .j  a  va2  s .  c  o  m
 */
public void stop() {
    if (mRunning) {
        mFinishTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = false;
        mParent.postInvalidate();
    }
}

From source file:br.com.leoleal.swipetorefresh.SwipeProgressBar.java

/**
 * Start showing the progress animation.
 *///from www. ja va2  s  . c  om
void start() {
    if (!mRunning) {
        mTriggerPercentage = 0;
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}

From source file:org.mozilla.gecko.animation.PropertyAnimator.java

public void start() {
    if (mDuration == 0) {
        return;/* ww w. j a v a 2  s . c  om*/
    }

    mStartTime = AnimationUtils.currentAnimationTimeMillis();

    // Fix the from value based on current position and property
    for (ElementHolder element : mElementsList) {
        if (element.property == Property.ALPHA)
            element.from = element.proxy.getAlpha();
        else if (element.property == Property.TRANSLATION_Y)
            element.from = element.proxy.getTranslationY();
        else if (element.property == Property.TRANSLATION_X)
            element.from = element.proxy.getTranslationX();
        else if (element.property == Property.SCROLL_Y)
            element.from = element.proxy.getScrollY();
        else if (element.property == Property.SCROLL_X)
            element.from = element.proxy.getScrollX();
        else if (element.property == Property.WIDTH)
            element.from = element.proxy.getWidth();
        else if (element.property == Property.HEIGHT)
            element.from = element.proxy.getHeight();

        ViewCompat.setHasTransientState(element.view, true);

        if (shouldEnableHardwareLayer(element))
            element.view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        else
            element.view.setDrawingCacheEnabled(true);
    }

    // Get ViewTreeObserver from any of the participant views
    // in the animation.
    final ViewTreeObserver treeObserver;
    if (mElementsList.size() > 0) {
        treeObserver = mElementsList.get(0).view.getViewTreeObserver();
    } else {
        treeObserver = null;
    }

    final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            if (treeObserver.isAlive()) {
                treeObserver.removeOnPreDrawListener(this);
            }

            mFramePoster.postFirstAnimationFrame();
            return true;
        }
    };

    // Try to start animation after any on-going layout round
    // in the current view tree. OnPreDrawListener seems broken
    // on pre-Honeycomb devices, start animation immediatelly
    // in this case.
    if (Versions.feature11Plus && treeObserver != null && treeObserver.isAlive()) {
        treeObserver.addOnPreDrawListener(preDrawListener);
    } else {
        mFramePoster.postFirstAnimationFrame();
    }

    if (mListeners != null) {
        for (PropertyAnimationListener listener : mListeners) {
            listener.onPropertyAnimationStart();
        }
    }
}

From source file:com.gavin.refreshlayout.refreshwidget.SwipeProgressBar.java

/**
 * Start showing the progress animation.
 *///  w ww . ja  va  2s  . c  om
public void start() {
    if (!mRunning) {
        mTriggerPercentage = 0;
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}

From source file:com.limxing.library.PullToRefresh.SwipeProgressBar.java

/**
 * Start showing the progress animation.
 */// ww  w. j a va2s  .  c  o  m
void start() {
    if (!mRunning) {
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}

From source file:com.hayukleung.app.view.refresh.SwipeProgressBar.java

/**
 * Start showing the progress animation.
 *///from   ww  w .  j  a  va 2 s .c  o m
void start() {
    if (!mRunning) {
        mTriggerPercentage = 0;
        mPercentage = 0;
        mStartTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = true;
        mParent.postInvalidate();
    }
}

From source file:br.com.leoleal.swipetorefresh.SwipeProgressBar.java

/**
 * Stop showing the progress animation.//  w  ww .  java2  s . c  om
 */
void stop() {
    if (mRunning) {
        mTriggerPercentage = 0;
        mFinishTime = AnimationUtils.currentAnimationTimeMillis();
        mRunning = false;
        mParent.postInvalidate();
    }
}