當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。