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


Java LinearLayoutManager.getChildCount方法代碼示例

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


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

示例1: onDraw

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final RecyclerView.LayoutManager manager = parent.getLayoutManager();
    if (manager instanceof StaggeredGridLayoutManager) {
        return;
    }

    //線性布局
    final LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
    final int firstItem = layoutManager.findFirstVisibleItemPosition();
    for (int i = 0; i < layoutManager.getChildCount(); i++) {
        final int viewAdapterPosition = firstItem + i;
        final View view = layoutManager.findViewByPosition(viewAdapterPosition);
        if (view != null) {
            mItemDecorationCallback.draw(c, mTextPaint, view,
                    mItemDecorationCallback.getItemOffsets(layoutManager, viewAdapterPosition),
                    layoutManager.getItemCount(), viewAdapterPosition);
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:21,代碼來源:RExItemDecoration.java

示例2: processLoadMoreData

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void processLoadMoreData() {
                LinearLayoutManager linearLayoutManager = (LinearLayoutManager) display.getLayoutManager();
                int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
                int totalCount = linearLayoutManager.getItemCount();
                int visibleCount = linearLayoutManager.getChildCount();
//                這裏分兩種情況,當緩慢滑動的時候,邊滑動邊加載,沒有接觸到底部。當如果快速滑動的時候,還沒加載完就滑動到底部
                if ((firstVisibleItemPosition + visibleCount >= totalCount) && !isLoading && totalCount != 1) {
                        LogUtil.e("底部加載拉");
                        if (mOnMoreDataLoadListener != null) {
                                isLoading = true;
                                moreLoadView.setVisibility(VISIBLE);
                                mOnMoreDataLoadListener.onMoreDataLoad(totalCount, firstVisibleItemPosition);
                        }
                }
        }
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:16,代碼來源:MultiFuncRecyclerView.java

示例3: needToRequestNextPage

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean needToRequestNextPage() {
  LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
  int visibleItemCount = layoutManager.getChildCount();
  int totalItemCount = getAdapter().getItemCount();
  int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
  return firstVisibleItemPosition > 0 && firstVisibleItemPosition + visibleItemCount > totalItemCount - 5;
}
 
開發者ID:jainsahab,項目名稱:AndroidSnooper,代碼行數:8,代碼來源:PaginatedRecyclerView.java

示例4: isAtLastElementOfLinearLayoutManager

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean isAtLastElementOfLinearLayoutManager(LinearLayoutManager linearLayoutManager) {
    visibleItemCount = linearLayoutManager.getChildCount();
    totalItemCount = linearLayoutManager.getItemCount();
    pastVisibleItems = linearLayoutManager.findFirstVisibleItemPosition();
    return (visibleItemCount + pastVisibleItems) >= totalItemCount - VISIBILITY_THRESHOLD;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:7,代碼來源:EndlessRecyclerOnScrollListener.java

示例5: onDraw

import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(c, parent, state);

    final RecyclerView.LayoutManager manager = parent.getLayoutManager();

    int itemCount = manager.getItemCount();
    if (itemCount < 1) {
        //如果隻有1個item, 直接返回;
        return;
    }
    if (manager instanceof GridLayoutManager) {
        //網格布局
        drawGrid(c, manager);
    } else if (manager instanceof StaggeredGridLayoutManager) {
        //暫不支持...
    } else {
        //線性布局
        final LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
        final int firstItem = layoutManager.findFirstVisibleItemPosition();
        for (int i = 0; i < layoutManager.getChildCount(); i++) {
            int adapterPosition = firstItem + i;

            final View view = layoutManager.findViewByPosition(adapterPosition);

            if (itemCount == 1 || adapterPosition == itemCount - 1) {
                //第一個, 或者最後一個
                if (!drawLastHLine && !drawLastVLine) {
                    continue;
                }
            }

            if (view != null) {
                if (layoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
                    //水平
                    drawDrawableV(c, view);
                } else {
                    //垂直
                    drawDrawableH(c, view);
                }
            }
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:45,代碼來源:RBaseItemDecoration.java


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