protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _scroller?.Dispose();
                _scroller = null;

                RecyclerView.RemoveOnScrollListener(_scrollListener);
                _scrollListener?.Dispose();
                _scrollListener = null;

                Adapter?.Dispose();
                Adapter = null;

                LayoutManager?.Dispose();
                LayoutManager = null;

                ((IListViewController)Element).ScrollToRequested -= OnScrollToRequested;
            }

            _disposed = true;
            base.Dispose(disposing);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CollectionView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                ((IListViewController)e.OldElement).ScrollToRequested -= OnScrollToRequested;
                if (Adapter != null)
                {
                    Adapter?.Dispose();
                    Adapter = null;
                }
            }

            if (e.NewElement != null)
            {
                ((IListViewController)e.NewElement).ScrollToRequested += OnScrollToRequested;
                _scroller = new SelectableSmoothScroller(Context);
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CollectionView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                if (RecyclerView == null)
                {
                    RecyclerView = new RecyclerView(Context);
                    _refresh     = new SwipeRefreshLayout(Context);
                    _refresh.SetOnRefreshListener(this);
                    _refresh.AddView(RecyclerView, LayoutParams.MatchParent, LayoutParams.MatchParent);

                    SetNativeControl(_refresh);
                }

                LayoutManager   = new GridLayoutManager(Context, 2);
                _spanSizeLookup = new CollectionViewSpanSizeLookup(this);
                _gridLayoutManager.SetSpanSizeLookup(_spanSizeLookup);

                RecyclerView.Focusable = false;
                RecyclerView.DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants;
                RecyclerView.OnFocusChangeListener  = this;
                RecyclerView.SetClipToPadding(false);

                _itemDecoration = new GridCollectionItemDecoration(this);
                RecyclerView.AddItemDecoration(_itemDecoration);

                Adapter = new CollectionViewAdapter(Context, _gridCollectionView, RecyclerView, this);

                RecyclerView.SetAdapter(Adapter);
                RecyclerView.SetLayoutManager(_gridLayoutManager);

                Adapter.IsAttachedToWindow = IsAttached;

                UpdateGroupHeaderHeight();
                UpdatePullToRefreshEnabled();
                UpdatePullToRefreshColor();
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CollectionView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                ((IListViewController)e.OldElement).ScrollToRequested -= OnScrollToRequested;
                if (Adapter != null)
                {
                    Adapter?.Dispose();
                    Adapter = null;
                }
                e.OldElement.SetLoadMoreCompletionAction = null;
            }

            if (e.NewElement != null)
            {
                ((IListViewController)e.NewElement).ScrollToRequested += OnScrollToRequested;
                _scroller       = new SelectableSmoothScroller(Context);
                _scrollListener = new CollectionViewScrollListener(e.NewElement);
                RecyclerView.AddOnScrollListener(_scrollListener);
                e.NewElement.SetLoadMoreCompletionAction = (isEnd) => _scrollListener.IsReachedBottom = isEnd;
            }
        }