protected virtual void TearDownOldElement(ItemsView oldElement) { if (oldElement == null) { return; } // Stop listening for layout property changes if (_layout != null) { _layout.PropertyChanged -= LayoutPropertyChanged; } // Stop listening for property changes oldElement.PropertyChanged -= OnElementPropertyChanged; // Stop listening for ScrollTo requests oldElement.ScrollToRequested -= ScrollToRequested; if (_recyclerViewScrollListener != null) { _recyclerViewScrollListener.Dispose(); ClearOnScrollListeners(); _recyclerViewScrollListener = null; } if (ItemsViewAdapter != null) { // Stop watching for empty items or scroll adjustments _emptyCollectionObserver.Stop(ItemsViewAdapter); _itemsUpdateScrollObserver.Stop(ItemsViewAdapter); // Unhook whichever adapter is active SetAdapter(null); _emptyViewAdapter?.Dispose(); ItemsViewAdapter?.Dispose(); } if (_snapManager != null) { _snapManager.Dispose(); _snapManager = null; } if (_itemDecoration != null) { RemoveItemDecoration(_itemDecoration); } }
protected virtual void TearDownOldElement(ItemsView oldElement) { if (oldElement == null) { return; } // Stop listening for layout property changes if (_layout != null) { _layout.PropertyChanged -= LayoutOnPropertyChanged; } // Stop listening for property changes oldElement.PropertyChanged -= OnElementPropertyChanged; // Stop listening for ScrollTo requests oldElement.ScrollToRequested -= ScrollToRequested; if (ItemsViewAdapter != null) { Unwatch(ItemsViewAdapter); SetAdapter(null); ItemsViewAdapter.Dispose(); } if (_snapManager != null) { _snapManager.Dispose(); _snapManager = null; } if (_itemDecoration != null) { RemoveItemDecoration(_itemDecoration); } }