Example #1
0
 /// <summary>
 /// Rows the selected.
 /// </summary>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     if (!_simpleCheck.Selected)
     {
         SelectedValue = _radioCell.Value;
     }
 }
Example #2
0
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     Execute?.Invoke();
     if (_CommandCell.KeepSelectedUntilBack)
     {
         adapter.SelectedRow(this, position);
     }
 }
        public override bool RowLongPressed(SettingsViewRecyclerAdapter adapter, int position)
        {
            if (CustomCell.LongCommand == null)
            {
                return(false);
            }

            CustomCell.SendLongCommand();

            return(true);
        }
 public void Dispose()
 {
     _root.SectionCollectionChanged -= OnRootSectionCollectionChanged;
     _root.CollectionChanged        -= OnRootCollectionChanged;
     _model   = null;
     _root    = null;
     _adapter = null;
     this?.Clear();
     ViewTypes?.Clear();
     ViewTypes = null;
 }
        public ModelProxy(SettingsView settingsView, SettingsViewRecyclerAdapter adapter)
        {
            _model   = settingsView.Model;
            _root    = settingsView.Root;
            _adapter = adapter;

            _root.SectionCollectionChanged += OnRootSectionCollectionChanged;
            _root.CollectionChanged        += OnRootCollectionChanged;

            FillProxy();
        }
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     if (!CustomCell.IsSelectable)
     {
         return;
     }
     Execute?.Invoke();
     if (CustomCell.KeepSelectedUntilBack)
     {
         adapter.SelectedRow(this, position);
     }
 }
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                // Fix scrollbar visibility and flash. https://github.com/xamarin/Xamarin.Forms/pull/10893
                var recyclerView = new RecyclerView(new ContextThemeWrapper(Context, Resource.Style.settingsViewTheme), null, Resource.Attribute.settingsViewStyle);
                recyclerView.NestedScrollingEnabled = false;

                // When replaced, No animation.
                //(recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = false;

                _layoutManager = new SettingsViewLayoutManager(Context, e.NewElement);
                recyclerView.SetLayoutManager(_layoutManager);

                _divider        = Context.GetDrawable(Resource.Drawable.divider);
                _itemDecoration = new SVItemdecoration(_divider, e.NewElement);
                recyclerView.AddItemDecoration(_itemDecoration);

                SetNativeControl(recyclerView);

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

                UpdateSeparatorColor();
                UpdateBackgroundColor();
                UpdateRowHeight();

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

                _simpleCallback  = new SettingsViewSimpleCallback(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;

                e.NewElement.Root.CollectionChanged += RootCollectionChanged;
            }
        }
        /// <summary>
        /// Dispose the specified disposing.
        /// </summary>
        /// <returns>The dispose.</returns>
        /// <param name="disposing">If set to <c>true</c> disposing.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                foreach (var section in Element.Root)
                {
                    if (section.HeaderView != null)
                    {
                        DisposeChildRenderer(section.HeaderView);
                    }
                    if (section.FooterView != null)
                    {
                        DisposeChildRenderer(section.FooterView);
                    }
                }

                foreach (var renderer in _shouldDisposeRenderers)
                {
                    if (renderer.View.Handle != IntPtr.Zero)
                    {
                        renderer.View.RemoveFromParent();
                        renderer.View.Dispose();
                    }
                    renderer.Dispose();
                }
                _shouldDisposeRenderers.Clear();
                _shouldDisposeRenderers = null;

                Control.RemoveItemDecoration(_itemDecoration);
                _parentPage.Appearing -= ParentPageAppearing;
                _adapter?.Dispose();
                _adapter = null;
                _layoutManager?.Dispose();
                _layoutManager = null;
                _simpleCallback?.Dispose();
                _simpleCallback = null;
                _itemTouchhelper?.Dispose();
                _itemTouchhelper = null;

                _itemDecoration?.Dispose();
                _itemDecoration = null;
                _divider?.Dispose();
                _divider = null;

                Element.Root.CollectionChanged -= RootCollectionChanged;
            }
            base.Dispose(disposing);
        }
Example #9
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <returns>The dispose.</returns>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 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);
 }
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var recyclerView = new RecyclerView(Context);
                _layoutManager = new SettingsViewLayoutManager(Context, e.NewElement);
                recyclerView.SetLayoutManager(_layoutManager);

                _divider        = Context.GetDrawable(Resource.Drawable.divider);
                _itemDecoration = new SVItemdecoration(_divider, e.NewElement);
                recyclerView.AddItemDecoration(_itemDecoration);

                SetNativeControl(recyclerView);

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

                UpdateSeparatorColor();
                UpdateBackgroundColor();
                UpdateRowHeight();

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

                _simpleCallback  = new SettingsViewSimpleCallback(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;

                e.NewElement.Root.CollectionChanged += RootCollectionChanged;
            }
        }
        /// <summary>
        /// Rows the selected.
        /// </summary>
        /// <param name="adapter">Adapter.</param>
        /// <param name="position">Position.</param>
        public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
        {
            if (_PickerCell.ItemsSource == null)
            {
                return;
            }

            if (_PickerCell.ItemsSource.Count == 0)
            {
                return;
            }

            if (_PickerCell.KeepSelectedUntilBack)
            {
                adapter.SelectedRow(this, position);
            }
            ShowDialog();
        }
Example #12
0
 /// <summary>
 /// Rows the selected.
 /// </summary>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     CreateDialog();
 }
Example #13
0
 /// <summary>
 /// Rows the long pressed.
 /// </summary>
 /// <returns><c>true</c>, if long pressed was rowed, <c>false</c> otherwise.</returns>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public virtual bool RowLongPressed(SettingsViewRecyclerAdapter adapter, int position)
 {
     return(false);
 }
Example #14
0
 /// <summary>
 /// Rows the selected.
 /// </summary>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public virtual void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
 }
 /// <summary>
 /// Rows the selected.
 /// </summary>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     Execute?.Invoke();
 }
Example #16
0
 /// <summary>
 /// Rows the selected.
 /// </summary>
 /// <param name="adapter">Adapter.</param>
 /// <param name="position">Position.</param>
 public override void RowSelected(SettingsViewRecyclerAdapter adapter, int position)
 {
     _switch.Checked = !_switch.Checked;
 }