Example #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _parentPage.Appearing -= ParentPageAppearing;
         _adapter?.Dispose();
         _adapter = null;
         _layoutManager?.Dispose();
         _layoutManager = null;
         _simpleCallback?.Dispose();
         _simpleCallback = null;
         _itemTouchhelper?.Dispose();
         _itemTouchhelper = null;
     }
     base.Dispose(disposing);
 }
Example #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <App.Controls.BoxedView.BoxedView> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                var recyclerView = new RecyclerView(Context);
                _layoutManager = new LinearLayoutManager(Context);
                recyclerView.SetLayoutManager(_layoutManager);

                SetNativeControl(recyclerView);

                Control.Focusable = false;
                Control.DescendantFocusability = DescendantFocusability.AfterDescendants;

                UpdateBackgroundColor();
                UpdateRowHeight();

                _adapter = new BoxedViewRecyclerAdapter(Context, e.NewElement, recyclerView);
                Control.SetAdapter(_adapter);

                _simpleCallback = new BoxedViewSimpleCallback(
                    e.NewElement, ItemTouchHelper.Up | ItemTouchHelper.Down, 0);
                _itemTouchhelper = new ItemTouchHelper(_simpleCallback);
                _itemTouchhelper.AttachToRecyclerView(Control);

                Element elm = Element;
                while (elm != null)
                {
                    elm = elm.Parent;
                    if (elm is Page)
                    {
                        break;
                    }
                }

                _parentPage            = elm as Page;
                _parentPage.Appearing += ParentPageAppearing;
            }
        }