protected override void OnElementChanged(ElementChangedEventArgs <CollectionView> e) { if (e.NewElement != null) { if (Control == null) { RecyclerView = new RecyclerView(Context); LayoutManager = new LinearLayoutManager(Context); LayoutManager.Orientation = LinearLayoutManager.Horizontal; SetNativeControl(RecyclerView); RecyclerView.Focusable = false; RecyclerView.DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants; RecyclerView.SetClipToPadding(false); RecyclerView.HorizontalScrollBarEnabled = false; _itemDecoration = new HSpacingDecoration(this); RecyclerView.AddItemDecoration(_itemDecoration); Adapter = new HCollectionViewAdapter(Context, e.NewElement, RecyclerView, this); RecyclerView.SetAdapter(Adapter); RecyclerView.SetLayoutManager(LayoutManager); UpdateIsInfinite(); UpdateSpacing(); } } base.OnElementChanged(e); }
protected override void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { RecyclerView?.StopScroll(); RecyclerView?.SetAdapter(null); RecyclerView?.RemoveItemDecoration(_itemDecoration); _itemDecoration?.Dispose(); _itemDecoration = null; } _disposed = true; base.Dispose(disposing); }