Java Code Examples for com.hippo.easyrecyclerview.LayoutManagerUtils

The following examples show how to use com.hippo.easyrecyclerview.LayoutManagerUtils. These examples are extracted from open source projects. 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 Project: MHViewer   Source File: ContentLayout.java    License: 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 Project: Nimingban   Source File: ContentLayout.java    License: 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 Project: EhViewer   Source File: ContentLayout.java    License: 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 Project: MHViewer   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example 5
Source Project: MHViewer   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example 6
Source Project: Nimingban   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example 7
Source Project: Nimingban   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example 8
Source Project: EhViewer   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForTop() {
    return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager()));
}
 
Example 9
Source Project: EhViewer   Source File: ContentLayout.java    License: Apache License 2.0 4 votes vote down vote up
public int getPageForBottom() {
    return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager()));
}