/// <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) { _dialog?.Dispose(); _dialog = null; _listView?.Dispose(); _listView = null; _adapter?.Dispose(); _adapter = null; _context = null; if (_notifyCollection != null) { _notifyCollection.CollectionChanged -= ItemsSourceCollectionChanged; _notifyCollection = null; } if (_selectedCollection != null) { _selectedCollection.CollectionChanged -= SelectedItems_CollectionChanged; _selectedCollection = null; } _indicatorView?.RemoveFromParent(); _indicatorView?.SetImageDrawable(null); _indicatorView?.SetImageBitmap(null); _indicatorView?.Dispose(); _indicatorView = null; } base.Dispose(disposing); }
/// <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) { // Dialog.Dispose() does not close an open dialog view so explicitly dismiss it before disposing _dialog?.Dismiss(); _dialog?.Dispose(); _dialog = null; _listView?.Dispose(); _listView = null; _adapter?.Dispose(); _adapter = null; _context = null; if (_notifyCollection != null) { _notifyCollection.CollectionChanged -= ItemsSourceCollectionChanged; _notifyCollection = null; } if (_selectedCollection != null) { _selectedCollection.CollectionChanged -= SelectedItems_CollectionChanged; _selectedCollection = null; } _indicatorView?.RemoveFromParent(); _indicatorView?.SetImageDrawable(null); _indicatorView?.SetImageBitmap(null); _indicatorView?.Dispose(); _indicatorView = null; } base.Dispose(disposing); }
void CreateDialog() { _listView = new AListView(_context); _listView.Focusable = false; _listView.DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants; _listView.SetPadding( (int)_context.ToPixels(_PickerCell.Padding.Left), (int)_context.ToPixels(_PickerCell.Padding.Top), (int)_context.ToPixels(_PickerCell.Padding.Right), (int)_context.ToPixels(_PickerCell.Padding.Bottom) ); _listView.SetDrawSelectorOnTop(true); _listView.ChoiceMode = _PickerCell.MaxSelectedNumber == 1 ? Android.Widget.ChoiceMode.Single : Android.Widget.ChoiceMode.Multiple; _adapter = new PickerAdapter(_context, _PickerCell, _listView); _listView.OnItemClickListener = _adapter; _listView.Adapter = _adapter; _adapter.CloseAction = () => { _dialog.GetButton((int)DialogButtonType.Positive).PerformClick(); }; if (_dialog == null) { using (var builder = new AlertDialog.Builder(_context)) { builder.SetTitle(_PickerCell.PageTitle); builder.SetView(_listView); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { ClearFocus(); }); builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => { _adapter.DoneSelect(); UpdateSelectedItems(); _PickerCell.InvokeCommand(); ClearFocus(); }); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.SetOnDismissListener(this); _dialog.SetOnShowListener(this); _dialog.Show(); // Pending //var buttonTextColor = _PickerCell.AccentColor.IsDefault ? Xamarin.Forms.Color.Accent.ToAndroid() : _PickerCell.AccentColor.ToAndroid(); //_dialog.GetButton((int)DialogButtonType.Positive).SetTextColor(buttonTextColor); //_dialog.GetButton((int)DialogButtonType.Negative).SetTextColor(buttonTextColor); } }
/// <summary> /// Ons the dismiss. /// </summary> /// <param name="dialog">Dialog.</param> public void OnDismiss(IDialogInterface dialog) { _dialog?.SetOnShowListener(null); _dialog?.SetOnDismissListener(null); _dialog?.Dispose(); _dialog = null; _adapter?.Dispose(); _adapter = null; _listView?.Dispose(); _listView = null; this.Selected = false; }
internal PickerInnerView(Android.Content.Context context, PickerAdapter adapter) : base(context) { this.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); var padding = (int)context.ToPixels(8); SetPadding(padding, padding, padding, padding); SetBackgroundColor(adapter._background); _textLabel = new TextView(context); _textLabel.Id = AView.GenerateViewId(); _detailLabel = new TextView(context); _detailLabel.Id = AView.GenerateViewId(); _textContainr = new LinearLayout(context); _textContainr.Orientation = Orientation.Vertical; using (var param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)){ _textContainr.AddView(_textLabel, param); _textContainr.AddView(_detailLabel, param); } _checkBox = new SimpleCheck(context); _checkBox.Focusable = false; _textLabel.SetTextColor(adapter._titleColor); _textLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)adapter._fontSize); _detailLabel.SetTextColor(adapter._detailColor); _detailLabel.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)adapter._detailFontSize); _checkBox.Color = adapter._accentColor; SetBackgroundColor(adapter._background); using (var param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) { param.AddRule(LayoutRules.AlignParentStart); param.AddRule(LayoutRules.CenterVertical); AddView(_textContainr, param); } using (var param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { Width = (int)context.ToPixels(30), Height = (int)context.ToPixels(30) }) { param.AddRule(LayoutRules.AlignParentEnd); param.AddRule(LayoutRules.CenterVertical); AddView(_checkBox, param); } }
/// <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) { _dialog?.Dispose(); _dialog = null; _listView?.Dispose(); _listView = null; _adapter?.Dispose(); _adapter = null; _context = null; } base.Dispose(disposing); }
/// <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) { _dialog?.Dispose(); _dialog = null; _listView?.Dispose(); _listView = null; _adapter?.Dispose(); _adapter = null; _context = null; if (_notifyCollection != null) { _notifyCollection.CollectionChanged -= ItemsSourceCollectionChanged; _notifyCollection = null; } } base.Dispose(disposing); }
void CreateDialog() { _listView = new AListView(_context); _listView.Focusable = false; _listView.DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants; _listView.SetDrawSelectorOnTop(true); _listView.ChoiceMode = _PickerCell.MaxSelectedNumber == 1 ? Android.Widget.ChoiceMode.Single : Android.Widget.ChoiceMode.Multiple; _adapter = new PickerAdapter(_context, _PickerCell, _listView); _listView.OnItemClickListener = _adapter; _listView.Adapter = _adapter; if (_dialog == null) { using (var builder = new AlertDialog.Builder(_context)) { builder.SetTitle(_PickerCell.PageTitle); builder.SetView(_listView); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { ClearFocus(); }); builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => { _adapter.DoneSelect(); UpdateSelectedItems(true); _PickerCell.InvokeCommand(); ClearFocus(); }); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.SetOnDismissListener(this); _dialog.SetOnShowListener(this); _dialog.Show(); } }