本文整理匯總了Java中android.support.v7.widget.StaggeredGridLayoutManager.findLastCompletelyVisibleItemPositions方法的典型用法代碼示例。如果您正苦於以下問題:Java StaggeredGridLayoutManager.findLastCompletelyVisibleItemPositions方法的具體用法?Java StaggeredGridLayoutManager.findLastCompletelyVisibleItemPositions怎麽用?Java StaggeredGridLayoutManager.findLastCompletelyVisibleItemPositions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.StaggeredGridLayoutManager
的用法示例。
在下文中一共展示了StaggeredGridLayoutManager.findLastCompletelyVisibleItemPositions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOnBottomListener
import android.support.v7.widget.StaggeredGridLayoutManager; //導入方法依賴的package包/類
RecyclerView.OnScrollListener getOnBottomListener(StaggeredGridLayoutManager layoutManager) {
return new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView rv, int dx, int dy) {
boolean isBottom =
layoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >=
mAdapter.getItemCount() - PRELOAD_SIZE;
if (!mRefreshLayout.isRefreshing() && isBottom) {
if (!mIsFirstTimeTouchBottom) {
mRefreshLayout.setRefreshing(true);
mPage += 1;
loadFromNet(false);
} else {
mIsFirstTimeTouchBottom = false;
}
}
}
};
}
示例2: onScrolled
import android.support.v7.widget.StaggeredGridLayoutManager; //導入方法依賴的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();
}
}
示例3: isLastItem
import android.support.v7.widget.StaggeredGridLayoutManager; //導入方法依賴的package包/類
private boolean isLastItem(RecyclerView.LayoutManager layoutManager) {
int totalItemCount = layoutManager.getItemCount();
if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager)
layoutManager;
if (null == mPositions) {
mPositions = new int[staggeredGridLayoutManager.getSpanCount()];
}
staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(mPositions);
return totalItemCount == getLast(mPositions) + 1;
} else if (layoutManager instanceof LinearLayoutManager){
return totalItemCount - 1 == ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition();
}
return false;
}
示例4: onScrolled
import android.support.v7.widget.StaggeredGridLayoutManager; //導入方法依賴的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();
}
}