コード例 #1
0
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

            int firstVisible = layoutManager.FindFirstVisibleItemPosition();
            int visibleCount = Math.Abs(firstVisible - layoutManager.FindLastVisibleItemPosition());
            int itemCount    = recyclerView.GetAdapter().ItemCount;

            if (firstVisible != lastFirstVisible ||
                visibleCount != lastVisibleCount ||
                itemCount != lastItemCount)
            {
                scrollListener.OnScroll(null, firstVisible, visibleCount, itemCount);
                lastFirstVisible = firstVisible;
                lastVisibleCount = visibleCount;
                lastItemCount    = itemCount;
            }
        }
コード例 #2
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: public final void onScroll(final android.widget.AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount)
        public void OnScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
        {
            /// <summary>
            /// Set whether the Last Item is Visible. lastVisibleItemIndex is a
            /// zero-based index, so we minus one totalItemCount to check
            /// </summary>
            if (null != mOnLastItemVisibleListener)
            {
                mLastItemVisible = (totalItemCount > 0) && (firstVisibleItem + visibleItemCount >= totalItemCount - 1);
            }

            // If we're showing the indicator, check positions...
            if (ShowIndicatorInternal)
            {
                updateIndicatorViewsVisibility();
            }

            // Finally call OnScrollListener if we have one
            if (null != mOnScrollListener)
            {
                mOnScrollListener.OnScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
            }
        }