当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法代码示例

本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的具体用法?Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition怎么用?Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.LinearLayoutManager的用法示例。


在下文中一共展示了LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOnBottomListener

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
RecyclerView.OnScrollListener getOnBottomListener(LinearLayoutManager layoutManager) {
    return new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView rv, int dx, int dy) {
            int lastItemPosition, firstItemPosition, itemCount;
            itemCount = mAdapter.getItemCount();
            lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
            firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
            if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
                mPresenter.requestData(HomePresenter.REQUEST_LOAD_MORE);
            } else if (firstItemPosition == 0) {
                isTransparent(true);
            } else {
                isTransparent(false);
            }
        }
    };
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:19,代码来源:MainActivity.java

示例2: renewScrollPosition

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
/**
 * This method calculates the current scroll position and its offset to help new attached
 * recyclerView on window at that position and offset
 *
 * @see #getScrollPosition()
 * @see #getScrollPositionOffset()
 */
private void renewScrollPosition(RecyclerView p_jRecyclerView) {
    LinearLayoutManager layoutManager = (LinearLayoutManager) p_jRecyclerView
            .getLayoutManager();
    m_nScrollPosition = layoutManager.findFirstCompletelyVisibleItemPosition();

    // That means there is no completely visible Position.
    if (m_nScrollPosition == -1) {
        m_nScrollPosition = layoutManager.findFirstVisibleItemPosition();

        // That means there is just a visible item on the screen
        if (layoutManager.findFirstVisibleItemPosition() == layoutManager
                .findLastVisibleItemPosition()) {
            // in this case we use the position which is the last & first visible item.
        } else {
            // That means there are 2 visible item on the screen. However, second one is not
            // completely visible.
            m_nScrollPosition = m_nScrollPosition + 1;
        }
    }

    m_nScrollPositionOffset = p_jRecyclerView.getLayoutManager().findViewByPosition
            (m_nScrollPosition).getLeft();
}
 
开发者ID:evrencoskun,项目名称:TableView,代码行数:31,代码来源:HorizontalRecyclerViewListener.java

示例3: bottomListener

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
    int lastItemPosition, firstItemPosition, itemCount;
    itemCount = mAdapter.getItemCount();
    lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
    firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
    if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
        mPresenter.requestData(ImagePresenter.REQUEST_LOAD_MORE);
    } else if (firstItemPosition == 0) {
        isTransparent(true);
    } else {
        isTransparent(true);
    }
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:14,代码来源:ImageActivity.java

示例4: bottomListener

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
    int lastItemPosition, firstItemPosition, itemCount;
    itemCount = mAdapter.getItemCount();
    lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
    firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
    if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
        mPresenter.requestData(IOSPresenter.REQUEST_LOAD_MORE);
    } else if (firstItemPosition == 0) {
        isTransparent(true);
    } else {
        isTransparent(false);
    }
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:14,代码来源:IOSActivity.java

示例5: bottomListener

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
    int lastItemPosition, firstItemPosition, itemCount;
    itemCount = mAdapter.getItemCount();
    lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
    firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
    if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0 && lastItemPosition != 0) {
        mPresenter.requestData(AndroidPresenter.REQUEST_LOAD_MORE);
    } else if (firstItemPosition == 0) {
        isTransparent(true);
    } else {
        isTransparent(false);
    }
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:14,代码来源:AndroidActivity.java

示例6: updateOverscrollMode

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void updateOverscrollMode() {
    LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
    if (lm.findFirstCompletelyVisibleItemPosition() == 0 &&
            lm.findLastCompletelyVisibleItemPosition() == mRecyclerView.getAdapter().getItemCount() - 1) {
        mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
    } else {
        mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_ALWAYS);
    }
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:10,代码来源:ListSearchView.java

示例7: initPendingList

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void initPendingList(@NonNull RecyclerView view, long timeOut,
                             ProductListItemCallback itemCallback){
    final LinearLayoutManager linearLayoutManager = (LinearLayoutManager)view.getLayoutManager();
    final int firstCompletelyItem = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
    final int lastCompletelyItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();

    for (int position = firstCompletelyItem; position <= lastCompletelyItem; position++){
        if (!mProductPositionItems.containsKey(position) && position >= 0) {
            mPendingProductPositionItems.put(position, itemCallback.getItem(position));
        }
    }

    mDelayHandler.postDelayed(mApplyPendingAction, timeOut);
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:15,代码来源:ProductListTracker.java

示例8: onScrolled

import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    int lastItem = 0;
    int firstItem = 0;
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    int totalItemCount = layoutManager.getItemCount();
    if (layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = ((GridLayoutManager) layoutManager);
        firstItem = gridLayoutManager.findFirstCompletelyVisibleItemPosition();
        //Position to find the final item of the current LayoutManager
        lastItem = gridLayoutManager.findLastCompletelyVisibleItemPosition();
        if (lastItem == -1) lastItem = gridLayoutManager.findLastVisibleItemPosition();
    } else if (layoutManager instanceof LinearLayoutManager) {
        LinearLayoutManager linearLayoutManager = ((LinearLayoutManager) layoutManager);
        firstItem = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
        lastItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
        if (lastItem == -1) lastItem = linearLayoutManager.findLastVisibleItemPosition();
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = ((StaggeredGridLayoutManager) layoutManager);
        // since may lead to the final item has more than one StaggeredGridLayoutManager the particularity of the so here that is an array
        // this array into an array of position and then take the maximum value that is the last show the position value
        int[] lastPositions = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
        staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(lastPositions);
        lastItem = findMax(lastPositions);
        firstItem = staggeredGridLayoutManager.findFirstVisibleItemPositions(lastPositions)[0];
    }
    if (firstItem == 0 || firstItem == RecyclerView.NO_POSITION) {
        if (mPullLoadMoreRecyclerView.getPullRefreshEnable())
            mPullLoadMoreRecyclerView.setSwipeRefreshEnable(true);
    } else {
        mPullLoadMoreRecyclerView.setSwipeRefreshEnable(false);
    }
    if (mPullLoadMoreRecyclerView.getPushRefreshEnable()
            && !mPullLoadMoreRecyclerView.isRefresh()
            && mPullLoadMoreRecyclerView.isHasMore()
            && (lastItem == totalItemCount - 1)
            && !mPullLoadMoreRecyclerView.isLoadMore()
            && (dx > 0 || dy > 0)) {
        mPullLoadMoreRecyclerView.setIsLoadMore(true);
        mPullLoadMoreRecyclerView.loadMore();
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:45,代码来源:RecyclerViewOnScroll.java


注:本文中的android.support.v7.widget.LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。