Skip to content

StaggeredGridView mScrollListener null #2

Description

@fanno

I don't need the listener in my case... sooo ...

@Override
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
    super.onScrollChanged(x, y, oldX, oldY);

    if ( Math.abs(y - oldY) < 2 || 
            y + getHeight() >= mTopLayout.getMeasuredHeight() ||
            y <= SCROLL_OFFSET+1 ) {
        if( mScrollListener != null ) {
            if( y <= SCROLL_OFFSET+1 ) {
                mScrollListener.onTop();
            } else if( y + getHeight() >= mTopLayout.getMeasuredHeight() ) {
                mScrollListener.onBottom();
            }
        }
    } else {
        mScrollListener.onScroll(); 
    }
}

Should be changed to:

@Override
protected void onScrollChanged(int x, int y, int oldX, int oldY) {
    super.onScrollChanged(x, y, oldX, oldY);

    if ( Math.abs(y - oldY) < 2 || 
            y + getHeight() >= mTopLayout.getMeasuredHeight() ||
            y <= SCROLL_OFFSET+1 ) {
        if( mScrollListener != null ) {
            if( y <= SCROLL_OFFSET+1 ) {
                mScrollListener.onTop();
            } else if( y + getHeight() >= mTopLayout.getMeasuredHeight() ) {
                mScrollListener.onBottom();
            }
        }
    } else {
        if( mScrollListener != null ) {
            mScrollListener.onScroll(); 
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions