本文整理匯總了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();
}
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
};
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}
示例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();
}
示例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();
}