當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearLayoutManager.findLastCompletelyVisibleItemPosition方法代碼示例

本文整理匯總了Java中android.support.v7.widget.LinearLayoutManager.findLastCompletelyVisibleItemPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayoutManager.findLastCompletelyVisibleItemPosition方法的具體用法?Java LinearLayoutManager.findLastCompletelyVisibleItemPosition怎麽用?Java LinearLayoutManager.findLastCompletelyVisibleItemPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.LinearLayoutManager的用法示例。


在下文中一共展示了LinearLayoutManager.findLastCompletelyVisibleItemPosition方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onScrollStateChanged

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
    super.onScrollStateChanged(recyclerView, newState);
    LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
    // 當不滑動時
    if (newState == RecyclerView.SCROLL_STATE_IDLE) {
        // 獲取最後一個完全顯示的itemPosition
        int lastItemPosition = manager.findLastCompletelyVisibleItemPosition();
        int itemCount = manager.getItemCount();

        // 判斷是否滑動到了最後一個item,並且是向上滑動
        if (lastItemPosition == (itemCount - 1) && isSlidingUpward) {
            // 加載更多
            onLoadMore();
        }
    }
}
 
開發者ID:alidili,項目名稱:Demos,代碼行數:18,代碼來源:EndlessRecyclerOnScrollListener.java

示例2: onScrolled

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
        layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();

        itemCount = layoutManager.getItemCount();
        lastPosition = layoutManager.findLastCompletelyVisibleItemPosition();
    } else {
        Log.e("OnLoadMoreListener", "The OnLoadMoreListener only support LinearLayoutManager");
        return;
    }

    if (lastItemCount != itemCount && lastPosition == itemCount - 1) {
        lastItemCount = itemCount;
        this.onLoadMore();
    }
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:18,代碼來源:OnLoadMoreListener.java

示例3: onScrolled

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    LoadMoreRecyclerView view = (LoadMoreRecyclerView) recyclerView;
    onLoadMoreListener onLoadMoreListener = view.getOnLoadMoreListener();

    onLoadMoreListener.onScrolled(recyclerView, dx, dy);

    //if scroll to bottom
    LinearLayoutManager layoutManager = (LinearLayoutManager) view.getLayoutManager();
    int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
    int itemCount = layoutManager.getItemCount();
    if (lastVisibleItem >= itemCount - 1 && !view.getLoadingMore()) {
        onLoadMoreListener.onLoadMore();
        L.i(TAG, "load more: lastVisibleItem = " + lastVisibleItem + ", itemCount " + itemCount);
    } else {
        super.onScrolled(recyclerView, dx, dy);
    }
}
 
開發者ID:Gookler,項目名稱:RxJanDan,代碼行數:19,代碼來源:LoadMoreRecyclerView.java

示例4: 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

示例5: onScrolled

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    if (dy < 0 || loadMoreSubject == null || loadMoreSubject.isLoading()){
        return;
    }

    int lastItem = 0;
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    int totalItemCount = layoutManager.getItemCount();
    if (layoutManager instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = ((GridLayoutManager) layoutManager);
        //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);
        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 = staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(null);
        lastItem = findMax(lastPositions);
    }
    final int childCount = layoutManager.getChildCount();
    final boolean shouldLoadMore = (childCount > 0 && lastItem >= totalItemCount - VISIBLE_THRESHOLD);
    if (shouldLoadMore) {
        loadMoreSubject.onLoadMore();
    }
}
 
開發者ID:yangjiantao,項目名稱:AndroidUiKit,代碼行數:36,代碼來源:LoadMoreDelegate.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: onScrolled

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView
                .getLayoutManager();
        int itemCount = layoutManager.getItemCount();
        int lastVisible = layoutManager.findLastCompletelyVisibleItemPosition();
        if (this.mLastLoad != itemCount && itemCount <= lastVisible + 1 && dy > 0) {
            this.mLastLoad = itemCount;
            onLoadMore();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:OnRecyclerLoadMoreListener.java

示例11: 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

示例12: 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

示例13: isLastMessageVisible

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean isLastMessageVisible() {
    LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
    int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
    return lastVisiblePosition >= adapter.getBottomDataPosition();
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:6,代碼來源:OnlinePeopleFragment.java

示例14: isLastMessageVisible

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean isLastMessageVisible() {
    LinearLayoutManager layoutManager = (LinearLayoutManager) messageListView.getLayoutManager();
    int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
    return lastVisiblePosition >= adapter.getBottomDataPosition();
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:6,代碼來源:ChatRoomMsgListPanel.java


注:本文中的android.support.v7.widget.LinearLayoutManager.findLastCompletelyVisibleItemPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。