FileDocCategorySizeDatePackage
TaskStackViewScroller.javaAPI DocAndroid 5.1 API7330Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.views

TaskStackViewScroller

public class TaskStackViewScroller extends Object

Fields Summary
com.android.systemui.recents.RecentsConfiguration
mConfig
TaskStackViewLayoutAlgorithm
mLayoutAlgorithm
TaskStackViewScrollerCallbacks
mCb
float
mStackScrollP
android.widget.OverScroller
mScroller
android.animation.ObjectAnimator
mScrollAnimator
float
mFinalAnimatedScroll
Constructors Summary
public TaskStackViewScroller(android.content.Context context, com.android.systemui.recents.RecentsConfiguration config, TaskStackViewLayoutAlgorithm layoutAlgorithm)

        mConfig = config;
        mScroller = new OverScroller(context);
        mLayoutAlgorithm = layoutAlgorithm;
        setStackScroll(getStackScroll());
    
Methods Summary
android.animation.ObjectAnimatoranimateBoundScroll()
Animates the stack scroll into bounds

        float curScroll = getStackScroll();
        float newScroll = getBoundedStackScroll(curScroll);
        if (Float.compare(newScroll, curScroll) != 0) {
            // Start a new scroll animation
            animateScroll(curScroll, newScroll, null);
        }
        return mScrollAnimator;
    
voidanimateScroll(float curScroll, float newScroll, java.lang.Runnable postRunnable)
Animates the stack scroll

        // Finish any current scrolling animations
        if (mScrollAnimator != null && mScrollAnimator.isRunning()) {
            setStackScroll(mFinalAnimatedScroll);
            mScroller.startScroll(0, progressToScrollRange(mFinalAnimatedScroll), 0, 0, 0);
        }
        stopScroller();
        stopBoundScrollAnimation();

        mFinalAnimatedScroll = newScroll;
        mScrollAnimator = ObjectAnimator.ofFloat(this, "stackScroll", curScroll, newScroll);
        mScrollAnimator.setDuration(mConfig.taskStackScrollDuration);
        mScrollAnimator.setInterpolator(mConfig.linearOutSlowInInterpolator);
        mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                setStackScroll((Float) animation.getAnimatedValue());
            }
        });
        mScrollAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (postRunnable != null) {
                    postRunnable.run();
                }
                mScrollAnimator.removeAllListeners();
            }
        });
        mScrollAnimator.start();
    
public booleanboundScroll()
Bounds the current scroll if necessary

        float curScroll = getStackScroll();
        float newScroll = getBoundedStackScroll(curScroll);
        if (Float.compare(newScroll, curScroll) != 0) {
            setStackScroll(newScroll);
            return true;
        }
        return false;
    
public booleanboundScrollRaw()
Bounds the current scroll if necessary, but does not synchronize the stack view with the model.

        float curScroll = getStackScroll();
        float newScroll = getBoundedStackScroll(curScroll);
        if (Float.compare(newScroll, curScroll) != 0) {
            setStackScrollRaw(newScroll);
            return true;
        }
        return false;
    
booleancomputeScroll()
Called from the view draw, computes the next scroll.

        if (mScroller.computeScrollOffset()) {
            float scroll = scrollRangeToProgress(mScroller.getCurrY());
            setStackScrollRaw(scroll);
            if (mCb != null) {
                mCb.onScrollChanged(scroll);
            }
            return true;
        }
        return false;
    
floatgetBoundedStackScroll(float scroll)
Returns the bounded stack scroll

        return Math.max(mLayoutAlgorithm.mMinScrollP, Math.min(mLayoutAlgorithm.mMaxScrollP, scroll));
    
floatgetScrollAmountOutOfBounds(float scroll)
Returns the amount that the aboslute value of how much the scroll is out of bounds.

        if (scroll < mLayoutAlgorithm.mMinScrollP) {
            return Math.abs(scroll - mLayoutAlgorithm.mMinScrollP);
        } else if (scroll > mLayoutAlgorithm.mMaxScrollP) {
            return Math.abs(scroll - mLayoutAlgorithm.mMaxScrollP);
        }
        return 0f;
    
public floatgetStackScroll()
Gets the current stack scroll

        return mStackScrollP;
    
booleanisScrollOutOfBounds()
Returns whether the specified scroll is out of bounds

        return Float.compare(getScrollAmountOutOfBounds(mStackScrollP), 0f) != 0;
    
booleanisScrolling()
Returns whether the overscroller is scrolling.

        return !mScroller.isFinished();
    
intprogressToScrollRange(float p)
OverScroller

        return (int) (p * mLayoutAlgorithm.mStackVisibleRect.height());
    
voidreset()
Resets the task scroller.

        mStackScrollP = 0f;
    
floatscrollRangeToProgress(int s)

        return (float) s / mLayoutAlgorithm.mStackVisibleRect.height();
    
voidsetCallbacks(com.android.systemui.recents.views.TaskStackViewScroller$TaskStackViewScrollerCallbacks cb)
Sets the callbacks

        mCb = cb;
    
public voidsetStackScroll(float s)
Sets the current stack scroll

        mStackScrollP = s;
        if (mCb != null) {
            mCb.onScrollChanged(mStackScrollP);
        }
    
voidsetStackScrollRaw(float s)
Sets the current stack scroll without calling the callback.

        mStackScrollP = s;
    
public booleansetStackScrollToInitialState()
Sets the current stack scroll to the initial state when you first enter recents.

return
whether the stack progress changed.

        float prevStackScrollP = mStackScrollP;
        setStackScroll(getBoundedStackScroll(mLayoutAlgorithm.mInitialScrollP));
        return Float.compare(prevStackScrollP, mStackScrollP) != 0;
    
voidstopBoundScrollAnimation()
Aborts any current stack scrolls

        Utilities.cancelAnimationWithoutCallbacks(mScrollAnimator);
    
voidstopScroller()
Stops the scroller and any current fling.

        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }