当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayoutManager.getItemCount方法代码示例

本文整理汇总了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;
}
 
开发者ID:liyuanhust,项目名称:LoadMoreHelper,代码行数:19,代码来源:PtrFramePullView.java

示例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();
        }
    }
}
 
开发者ID:1014277960,项目名称:DailyReader,代码行数:22,代码来源:FooterRVAdapter.java

示例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();
    }
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:18,代码来源:OnLoadMoreListener.java

示例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);
    }
}
 
开发者ID:Gookler,项目名称:RxJanDan,代码行数:19,代码来源:LoadMoreRecyclerView.java

示例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;
    }
    // 여기까지 툴바 숨기기
}
 
开发者ID:pooi,项目名称:Nearby,代码行数:34,代码来源:RecordPatientRemarkListCustomAdapter.java

示例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);
}
 
开发者ID:vivchar,项目名称:RendererRecyclerViewAdapter,代码行数:11,代码来源:EndlessScrollListener.java

示例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;
}
 
开发者ID:Zeyad-37,项目名称:RxRedux,代码行数:14,代码来源:ScrollEventCalculator.java

示例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;
}
 
开发者ID:liying2008,项目名称:SmartisanDialog,代码行数:13,代码来源:DividerLineDecoration.java


注:本文中的android.support.v7.widget.LinearLayoutManager.getItemCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。