FileDocCategorySizeDatePackage
ObservableScrollView.javaAPI DocAndroid 5.1 API4699Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar.phone

ObservableScrollView

public class ObservableScrollView extends android.widget.ScrollView
A scroll view which can be observed for scroll change events.

Fields Summary
private Listener
mListener
private int
mLastOverscrollAmount
private boolean
mTouchEnabled
private boolean
mHandlingTouchEvent
private float
mLastX
private float
mLastY
private boolean
mBlockFlinging
private boolean
mTouchCancelled
Constructors Summary
public ObservableScrollView(android.content.Context context, android.util.AttributeSet attrs)


         
        super(context, attrs);
    
Methods Summary
public booleandispatchTouchEvent(android.view.MotionEvent ev)

        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            if (!mTouchEnabled) {
                mTouchCancelled = true;
                return false;
            }
            mTouchCancelled = false;
        } else if (mTouchCancelled) {
            return false;
        } else if (!mTouchEnabled) {
            MotionEvent cancel = MotionEvent.obtain(ev);
            cancel.setAction(MotionEvent.ACTION_CANCEL);
            super.dispatchTouchEvent(ev);
            cancel.recycle();
            mTouchCancelled = true;
            return false;
        }
        return super.dispatchTouchEvent(ev);
    
public voidfling(int velocityY)

        if (!mBlockFlinging) {
            super.fling(velocityY);
        }
    
private intgetMaxScrollY()

        int scrollRange = 0;
        if (getChildCount() > 0) {
            View child = getChildAt(0);
            scrollRange = Math.max(0,
                    child.getHeight() - (getHeight() - mPaddingBottom - mPaddingTop));
        }
        return scrollRange;
    
public booleanisHandlingTouchEvent()

        return mHandlingTouchEvent;
    
public booleanisScrolledToBottom()

        return getScrollY() == getMaxScrollY();
    
public booleanonInterceptTouchEvent(android.view.MotionEvent ev)

        mHandlingTouchEvent = true;
        mLastX = ev.getX();
        mLastY = ev.getY();
        boolean result = super.onInterceptTouchEvent(ev);
        mHandlingTouchEvent = false;
        return result;
    
protected voidonOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY)

        super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
        if (mListener != null && mLastOverscrollAmount > 0) {
            mListener.onOverscrolled(mLastX, mLastY, mLastOverscrollAmount);
        }
    
protected voidonScrollChanged(int l, int t, int oldl, int oldt)

        super.onScrollChanged(l, t, oldl, oldt);
        if (mListener != null) {
            mListener.onScrollChanged();
        }
    
public booleanonTouchEvent(android.view.MotionEvent ev)

        mHandlingTouchEvent = true;
        mLastX = ev.getX();
        mLastY = ev.getY();
        boolean result = super.onTouchEvent(ev);
        mHandlingTouchEvent = false;
        return result;
    
protected booleanoverScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent)

        mLastOverscrollAmount = Math.max(0, scrollY + deltaY - getMaxScrollY());
        return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY,
                        maxOverScrollX, maxOverScrollY, isTouchEvent);
    
public voidsetBlockFlinging(boolean blockFlinging)

        mBlockFlinging = blockFlinging;
    
public voidsetListener(com.android.systemui.statusbar.phone.ObservableScrollView$Listener listener)

        mListener = listener;
    
public voidsetTouchEnabled(boolean touchEnabled)

        mTouchEnabled = touchEnabled;