當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。