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; } 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; } }