com.hippo.easyrecyclerview.LayoutManagerUtils Java Examples

The following examples show how to use com.hippo.easyrecyclerview.LayoutManagerUtils. 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: ContentLayout.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
/**
 * Check range first!
 *
 * @param page the target page
 * @throws IndexOutOfBoundsException
 */
public void goTo(int page) throws IndexOutOfBoundsException {
    if (page < 0 || page >= mPages) {
        throw new IndexOutOfBoundsException("Page count is " + mPages + ", page is " + page);
    } else if (page >= mStartPage && page < mEndPage) {
        cancelCurrentTask();

        int position = getPageStart(page);
        mRecyclerView.stopScroll();
        LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), position, 0);
        onScrollToPosition(position);
    } else if (page == mStartPage - 1) {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_PRE_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else if (page == mEndPage) {
        mRefreshLayout.setHeaderRefreshing(false);
        mRefreshLayout.setFooterRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_NEXT_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_SOMEWHERE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    }
}
 
Example #2
Source File: ContentLayout.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
/**
 * Check range first!
 *
 * @param page the targe page
 * @throws IndexOutOfBoundsException
 */
public void goTo(int page) throws IndexOutOfBoundsException {
    if (page < 0 || page >= mPages) {
        throw new IndexOutOfBoundsException("Page count is " + mPages + ", page is " + page);
    } else if (page >= mStartPage && page < mEndPage) {
        cancelCurrentTask();

        int position = getPageStart(page);
        mRecyclerView.stopScroll();
        LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), position, 0);
        onScrollToPosition();
    } else if (page == mStartPage - 1) {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_PRE_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else if (page == mEndPage) {
        mRefreshLayout.setHeaderRefreshing(false);
        mRefreshLayout.setFooterRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_NEXT_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_SOMEWHERE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    }
}
 
Example #3
Source File: ContentLayout.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
/**
 * Check range first!
 *
 * @param page the target page
 * @throws IndexOutOfBoundsException
 */
public void goTo(int page) throws IndexOutOfBoundsException {
    if (page < 0 || page >= mPages) {
        throw new IndexOutOfBoundsException("Page count is " + mPages + ", page is " + page);
    } else if (page >= mStartPage && page < mEndPage) {
        cancelCurrentTask();

        int position = getPageStart(page);
        mRecyclerView.stopScroll();
        LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), position, 0);
        onScrollToPosition(position);
    } else if (page == mStartPage - 1) {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_PRE_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else if (page == mEndPage) {
        mRefreshLayout.setHeaderRefreshing(false);
        mRefreshLayout.setFooterRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_NEXT_PAGE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    } else {
        mRefreshLayout.setFooterRefreshing(false);
        mRefreshLayout.setHeaderRefreshing(true);

        mCurrentTaskId = mIdGenerator.nextId();
        mCurrentTaskType = TYPE_SOMEWHERE;
        mCurrentTaskPage = page;
        getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
    }
}
 
Example #4
Source File: ContentLayout.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example #5
Source File: ContentLayout.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example #6
Source File: ContentLayout.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example #7
Source File: ContentLayout.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example #8
Source File: ContentLayout.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example #9
Source File: ContentLayout.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}