android.graphics.Interpolator Java Examples

The following examples show how to use android.graphics.Interpolator. 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: CustomScrollView.java    From FirefoxReality with Mozilla Public License 2.0 6 votes vote down vote up
public void run() {
    long now = AnimationUtils.currentAnimationTimeMillis();
    if (now >= mFadeStartTime) {
        int nextFrame = (int) now;
        int framesCount = 0;

        Interpolator interpolator = mScrollBarInterpolator;
        interpolator.setKeyFrame(framesCount++, nextFrame, OPAQUE);

        nextFrame += mScrollBarFadeDuration;
        interpolator.setKeyFrame(framesCount, nextFrame, TRANSPARENT);

        mState = ScrollAnimatorState.FADING;

        mHost.invalidate();
    }
}
 
Example #2
Source File: FastScrollDelegate.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
public void run() {
	long now = AnimationUtils.currentAnimationTimeMillis();
	if (now >= fadeStartTime) {

		// the animation fades the scrollbars out by changing
		// the opacity (alpha) from fully opaque to fully
		// transparent
		int nextFrame = (int) now;
		int framesCount = 0;

		Interpolator interpolator = scrollBarInterpolator;

		// Start opaque
		interpolator.setKeyFrame(framesCount++, nextFrame, OPAQUE);

		// End transparent
		nextFrame += scrollBarFadeDuration;
		interpolator.setKeyFrame(framesCount, nextFrame, TRANSPARENT);

		state = FADING;

		// Kick off the fade animation
		// host.invalidate(true);
		host.invalidate();
	}
}
 
Example #3
Source File: CustomScrollView.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
private void drawScrollBars(Canvas canvas) {
    boolean invalidate = false;
    if (mIsHandlingTouchEvent) {
        mThumbDrawable.setAlpha(255);

    } else {
        if (!mIsAlwaysVisible) {
            final ScrollAnimator cache = mScrollCache;
            final ScrollAnimatorState state = cache.mState;
            if (state == ScrollAnimatorState.OFF) {
                return;
            }
            if (state == ScrollAnimatorState.FADING) {
                if (cache.mInterpolatorValues == null) {
                    cache.mInterpolatorValues = new float[1];
                }
                float[] values = cache.mInterpolatorValues;
                if (cache.mScrollBarInterpolator.timeToValues(values) == Interpolator.Result.FREEZE_END) {
                    cache.mState = ScrollAnimatorState.OFF;
                } else {
                    mThumbDrawable.setAlpha(Math.round(values[0]));
                }
                invalidate = true;

            } else {
                mThumbDrawable.setAlpha(255);
            }
        }
    }

    if (updateThumbRect(0)) {
        final int scrollY = getScrollY();
        final int scrollX = getScrollX();
        mThumbDrawable.setBounds(mThumbRect.left + scrollX, mThumbRect.top + scrollY, mThumbRect.right + scrollX,
                mThumbRect.bottom + scrollY);
        mThumbDrawable.draw(canvas);
    }
    if (invalidate) {
        invalidate();
    }
}
 
Example #4
Source File: FastScrollDelegate.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
private void onDrawScrollBars(Canvas canvas) {
	boolean invalidate = false;
	if (mIsHanlingTouchEvent) {
		mThumbDrawable.setAlpha(255);
	} else {
		// Copy from View.class
		final ScrollabilityCache cache = mScrollCache;
		// cache.scrollBar = mThumbDrawable;
		final int state = cache.state;
		if (state == ScrollabilityCache.OFF) {
			return;
		}
		if (state == ScrollabilityCache.FADING) {
			// We're fading -- get our fade interpolation
			if (cache.interpolatorValues == null) {
				cache.interpolatorValues = new float[1];
			}
			float[] values = cache.interpolatorValues;
			// Stops the animation if we're done
			if (cache.scrollBarInterpolator.timeToValues(values) == Interpolator.Result.FREEZE_END) {
				cache.state = ScrollabilityCache.OFF;
			} else {
				// in View.class is "cache.scrollBar.mutate()"
				mThumbDrawable.setAlpha(Math.round(values[0]));
			}
			invalidate = true;
		} else {
			// reset alpha, in View.class is "cache.scrollBar.mutate()"
			mThumbDrawable.setAlpha(255);
		}
	}

	// Draw the thumb
	if (updateThumbRect(0)) {
		final int scrollY = mView.getScrollY();
		final int scrollX = mView.getScrollX();
		mThumbDrawable.setBounds(mThumbRect.left + scrollX, mThumbRect.top + scrollY, mThumbRect.right + scrollX,
				mThumbRect.bottom + scrollY);
		mThumbDrawable.draw(canvas);
	}
	if (invalidate) {
		mView.invalidate();
	}

}
 
Example #5
Source File: InterpolatorAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public InterpolatorAssert(Interpolator actual) {
  super(actual, InterpolatorAssert.class);
}