本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.getItemCount方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.getItemCount方法的具体用法?Java LinearLayoutManager.getItemCount怎么用?Java LinearLayoutManager.getItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.getItemCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRecyclerView
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private static boolean checkRecyclerView(RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
if (linearLayoutManager.getItemCount() == 0) {
return true;
}
int firstVisiblePosition = linearLayoutManager.findFirstVisibleItemPosition();
if (firstVisiblePosition == 0) {
View firstVisibleView = linearLayoutManager.findViewByPosition(firstVisiblePosition);
int top = firstVisibleView.getTop();
return top >= 0;
} else {
return false;
}
}
return false;
}
示例2: onScrolled
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// 锁定触发
if (loading) {
return;
}
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
int lastVisiblePosition = layoutManager.findLastVisibleItemPosition();
int itemCount = layoutManager.getItemCount();
// 最后一个item刚出现且还能上滑的时候触发并锁定防止多次触发,提前触发以便无缝衔接,需要用户加载完数据后手动解锁
if (recyclerView.canScrollVertically(1) && (lastVisiblePosition == itemCount - 1)) {
Log.d("Debug", "OnLoadMore...");
if (mLoadMoreListener != null) {
mLoadMoreListener.onLoadMore();
loading = true;
notifyDataSetChanged();
}
}
}
示例3: 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();
}
}
示例4: 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);
}
}
示例5: onScrolled
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!loading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
loading = true;
if (onLoadMoreListener != null) {
onLoadMoreListener.onLoadMore();
}
}
// 여기까지 무한 스크롤
if (scrolledDistance > HIDE_THRESHOLD && controlsVisible) {
onHide();
controlsVisible = false;
scrolledDistance = 0;
} else if (scrolledDistance < -HIDE_THRESHOLD && !controlsVisible) {
onShow();
controlsVisible = true;
scrolledDistance = 0;
}
if((controlsVisible && dy>0) || (!controlsVisible && dy<0)) {
scrolledDistance += dy;
}
// 여기까지 툴바 숨기기
}
示例6: onScrolled
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(final RecyclerView mRecyclerView, final int dx, final int dy) {
super.onScrolled(mRecyclerView, dx, dy);
final LinearLayoutManager mLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
visibleItemCount = mRecyclerView.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
onScroll(firstVisibleItem, visibleItemCount, totalItemCount);
}
示例7: isAtScrollEnd
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
/**
* Determine if the scroll event at the end of the recycler view.
*
* @return true if at end of linear list recycler view, false otherwise.
*/
static boolean isAtScrollEnd(RecyclerViewScrollEvent recyclerViewScrollEvent) {
RecyclerView.LayoutManager layoutManager = recyclerViewScrollEvent.view().getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
return linearLayoutManager.getItemCount() <= (linearLayoutManager.findLastVisibleItemPosition() + 2);
}
return false;
}
示例8: getItemOffsets
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
if (parent.getChildAdapterPosition(view) == layoutManager.getItemCount() - 1) {
outRect.bottom = 0;
} else {
outRect.bottom = mDivider.getIntrinsicHeight();
}
outRect.top = 0;
outRect.left = 0;
outRect.right = 0;
}