Beispiel #1
0
        private void Init()
        {
            _mChildrenHeights = new SparseIntArray();
            _mHeaderViewInfos = new List <FixedViewInfo>();
            _mFooterViewInfos = new List <FixedViewInfo>();
            base.SetClipChildren(false);

            ScrollStateChanged += (sender, args) =>
            {
                if (_mOriginalScrollListener != null)
                {
                    _mOriginalScrollListener.OnScrollStateChanged(args.View, args.ScrollState);
                }
            };

            Scroll += (sender, args) =>
            {
                if (_mOriginalScrollListener != null)
                {
                    _mOriginalScrollListener.OnScroll(args.View, args.FirstVisibleItem, args.VisibleItemCount, args.TotalItemCount);
                }
                // AbsListView#invokeOnItemScrollListener calls onScrollChanged(0, 0, 0, 0)
                // on Android 4.0+, but Android 2.3 is not. (Android 3.0 is unknown)
                // So call it with onScrollListener.
                OnScrollChanged();
            };
        }
Beispiel #2
0
        public override void OnScrolled(Android.Support.V7.Widget.RecyclerView recyclerView, int dx, int dy)
        {
            LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

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

            if (firstVisible != _lastFirstVisible || visibleCount != _lastVisibleCount || itemCount != _lastItemCount)
            {
                _scrollListener.OnScroll(null, firstVisible, visibleCount, itemCount);
                _lastVisibleCount = firstVisible;
                _lastVisibleCount = visibleCount;
                _lastItemCount    = itemCount;
            }
        }