internal nfloat CalculateHeightForCell(UITableView tableView, Cell cell) { var viewCell = cell as ViewCell; if (viewCell != null && viewCell.View != null) { var target = viewCell.View; if (_prototype == null) { _prototype = Platform.CreateRenderer(target); } else { _prototype.SetElement(target); } Platform.SetRenderer(target, _prototype); var req = target.Measure(tableView.Frame.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins); target.ClearValue(Platform.RendererProperty); foreach (Element descendant in target.Descendants()) { IVisualElementRenderer renderer = Platform.GetRenderer(descendant as VisualElement); descendant.ClearValue(Platform.RendererProperty); renderer?.Dispose(); } return((nfloat)req.Request.Height); } var renderHeight = cell.RenderHeight; return(renderHeight > 0 ? (nfloat)renderHeight : DefaultRowHeight); }
private void AddContentRenderer() { _renderer?.Dispose(); _renderer = Platform.CreateRenderer(_content); _nativeView?.RemoveFromSuperview(); if (_content == null) { return; } _nativeView = _renderer.NativeView; SetNativeControl(_view); _scrollContent.Add(_nativeView); var type = Type.GetType("Xamarin.Forms.Platform.iOS.Platform,Xamarin.Forms.Platform.iOS"); if (type != null) { var field = type.GetField("RendererProperty", BindingFlags.Static | BindingFlags.Public); if (field != null) { _content.SetValue((BindableProperty)field.GetValue(null), _renderer); } } LayoutContent(); }
void RemovePage(Page page) { IVisualElementRenderer rendererToRemove = Android.Platform.GetRenderer(page); if (rendererToRemove != null) { var containerToRemove = (PageContainer)rendererToRemove.View.Parent; rendererToRemove.View?.RemoveFromParent(); rendererToRemove?.Dispose(); // This causes a NullPointerException in API 25.1+ when we later call ExecutePendingTransactions(); // We may want to remove this in the future if it is resolved in the Android SDK. if ((int)Build.VERSION.SdkInt < 25) { containerToRemove?.RemoveFromParent(); containerToRemove?.Dispose(); } } // Also remove this page from the fragmentStack FilterPageFragment(page); Device.StartTimer(TimeSpan.FromMilliseconds(10), () => { UpdateToolbar(); return(false); }); }
// Use OnDestroy instead of OnDestroyView because OnDestroyView will be // called before the animation completes. This causes tons of tiny issues. public override void OnDestroy() { base.OnDestroy(); _shellPageContainer.RemoveAllViews(); _renderer?.Dispose(); _root?.Dispose(); _toolbarTracker.Dispose(); _appearanceTracker.Dispose(); ((IShellController)_shellContext.Shell).RemoveAppearanceObserver(this); if (_shellContent != null) { ((IShellContentController)_shellContent).RecyclePage(_page); _page.ClearValue(Platform.RendererProperty); _page = null; } _appearanceTracker = null; _toolbar = null; _toolbarTracker = null; _root = null; _renderer = null; }
/// <summary> /// Cleanup layout. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); isDisposed = true; if (disposing) { if (Element != null) { Element.PropertyChanged -= HandlePropertyChanged; } if (packed != null) { RemoveView(packed.View); } } packed?.Dispose(); packed = null; Tracker?.Dispose(); Tracker = null; if (rendererProperty != null) { rendererProperty = null; } init = false; }
protected override void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_formsCell != null) { _formsCell.PropertyChanged -= CellPropertyChanged; } CustomCell = null; _heightConstraint?.Dispose(); _heightConstraint = null; IVisualElementRenderer renderer = null; if (_rendererRef != null && _rendererRef.TryGetTarget(out renderer) && renderer.Element != null) { FormsInternals.DisposeModelAndChildrenRenderers(renderer.Element); _rendererRef = null; } renderer?.Dispose(); _formsCell = null; } _disposed = true; base.Dispose(disposing); }
void DisposeChildRenderers() { IVisualElementRenderer childRenderer = Platform.GetRenderer(_childView); childRenderer?.Dispose(); _childView?.ClearValue(Platform.RendererProperty); }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { _disposed = true; if (Element != null) { foreach (Element element in PageController.InternalChildren) { var child = (VisualElement)element; if (child == null) { continue; } IVisualElementRenderer renderer = Platform.GetRenderer(child); renderer?.Dispose(); } var navController = (INavigationPageController)Element; navController.PushRequested -= OnPushed; navController.PopRequested -= OnPopped; navController.PopToRootRequested -= OnPoppedToRoot; navController.InsertPageBeforeRequested -= OnInsertPageBeforeRequested; navController.RemovePageRequested -= OnRemovePageRequested; } } base.Dispose(disposing); }
void Destroy() { ((IShellController)_shellContext.Shell).RemoveAppearanceObserver(this); if (_shellContent != null) { ((IShellContentController)_shellContent).RecyclePage(_page); _page.ClearValue(AppCompat.Platform.RendererProperty); _page = null; } if (_shellPageContainer != null) { _shellPageContainer.RemoveAllViews(); if (_root is ViewGroup vg) { vg.RemoveView(_shellPageContainer); } } _renderer?.Dispose(); _root?.Dispose(); _toolbarTracker?.Dispose(); _appearanceTracker?.Dispose(); _appearanceTracker = null; _toolbarTracker = null; _toolbar = null; _root = null; _renderer = null; _shellContent = null; }
protected override void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { if (Element != null) { Element.PropertyChanged -= HandlePropertyChanged; } if (_renderer != null) { _renderer.View.RemoveFromParent(); } _renderer?.Dispose(); _renderer = null; Tracker?.Dispose(); Tracker = null; _init = false; } _isDisposed = true; base.Dispose(disposing); }
/// <summary> /// Cleanup layout. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (Element != null) { Element.PropertyChanged -= HandleElementPropertyChanged; } if (_packed != null) { RemoveView(_packed.View); } } _packed?.Dispose(); _packed = null; Tracker?.Dispose(); Tracker = null; _rendererProperty = null; _init = false; }
void Cleanup(List <AView> viewsToRemove, List <IVisualElementRenderer> renderersToDispose) { // If trigger by dispose, cleanup now, otherwise queue it for later if (_disposed) { DoCleanup(); } else { new Handler(Looper.MainLooper).Post(DoCleanup); } void DoCleanup() { for (int i = 0; i < viewsToRemove.Count; i++) { AView view = viewsToRemove[i]; _renderer?.RemoveView(view); } for (int i = 0; i < renderersToDispose.Count; i++) { IVisualElementRenderer rootRenderer = renderersToDispose[i]; rootRenderer?.Element.ClearValue(Android.Platform.RendererProperty); rootRenderer?.Dispose(); } } }
public void TearDown() { View = null; _renderer?.Dispose(); _renderer = null; _view = null; _context = null; }
void ClearContentRenderer() { if ((ContentView as FlippedClipView) != null) { (ContentView as FlippedClipView).ContentRenderer = null; } _contentRenderer?.NativeView?.RemoveFromSuperview(); _contentRenderer?.Dispose(); _contentRenderer = null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _renderer?.Dispose(); _renderer = null; _view = null; } }
protected override void Dispose(bool disposing) { if (disposing) { _gestureLayer?.Unrealize(); _gestureLayer = null; _itemsRenderer?.Dispose(); _itemsRenderer = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { _renderer?.Dispose(); _renderer = null; _view.ClearValue(Platform.RendererProperty); _disposed = true; } base.Dispose(disposing); }
void Cleanup(List <AView> viewsToRemove, List <IVisualElementRenderer> renderersToDispose) { for (int i = 0; i < viewsToRemove.Count; i++) { AView view = viewsToRemove[i]; _renderer?.RemoveView(view); } for (int i = 0; i < renderersToDispose.Count; i++) { IVisualElementRenderer rootRenderer = renderersToDispose[i]; rootRenderer?.Dispose(); } }
static void DisposeRenderer(Element view) { IVisualElementRenderer renderer = GetRenderer((VisualElement)view); if (renderer?.ViewController?.ParentViewController != null) { renderer?.ViewController?.RemoveFromParentViewController(); } renderer?.NativeView?.RemoveFromSuperview(); renderer?.Dispose(); view.ClearValue(RendererProperty); }
void ClearMaster() { if (_master == null) { return; } _master.PropertyChanged -= OnMasterPropertyChanged; IVisualElementRenderer renderer = Platform.GetRenderer(_master); renderer?.Dispose(); _master.ClearValue(Platform.RendererProperty); _master = null; }
internal void Recycle() { if (Content?.Element != null) { Content.Element.MeasureInvalidated -= ElementMeasureInvalidated; } if (Content?.View != null) { RemoveView(Content.View); } Content?.Dispose(); Content = null; _size = null; }
void ClearDetail() { ((ITitleProvider)this).ShowTitle = false; if (_detail == null) { return; } _detail.PropertyChanged -= OnDetailPropertyChanged; IVisualElementRenderer renderer = Platform.GetRenderer(_detail); renderer?.Dispose(); _detail.ClearValue(Platform.RendererProperty); _detail = null; }
public override void Dispose() { _loadingView.Destroy(); _loadingView.BindingContext = null; _loadingView.Parent = null; _loadingView = null; if (_renderer != null) { if (!_renderer.View.IsDisposed()) { _renderer.View.Dispose(); } _renderer?.Dispose(); _renderer = null; } base.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing) { if (_formsCell != null) { _formsCell.PropertyChanged -= CellPropertyChanged; _formsCell = null; } CustomCell = null; ViewHolder = null; _renderer?.View?.RemoveFromParent(); _renderer?.Dispose(); _renderer = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { if (_contentCell != null) { _contentCell.PropertyChanged -= CellPropertyChanged; CellParent.PropertyChanged -= ParentPropertyChanged; _contentCell = null; } ViewHolder = null; _contentViewRenderer?.View?.RemoveFromParent(); _contentViewRenderer?.Dispose(); _contentViewRenderer = null; } base.Dispose(disposing); }
void ClearDetail() { ((ITitleProvider)this).ShowTitle = false; if (_detail == null) { return; } if (!_detail.GetRetainsRendererValue()) { _detail.PropertyChanged -= OnDetailPropertyChanged; IVisualElementRenderer renderer = Platform.GetRenderer(_detail); Control.RemoveContent(renderer.ContainerElement); renderer?.Dispose(); _detail.ClearValue(Platform.RendererProperty); _detail = null; } }
protected override void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { if (_listview != null) { _listview.MouseUp -= OnNativeMouseUp; _listview.KeyUp -= OnNativeKeyUp; _listview.TouchUp -= OnNativeTouchUp; _listview.StylusUp -= OnNativeStylusUp; _listview.Loaded -= ControlOnLoaded; } if (_scrollViewer != null) { _scrollViewer.ScrollChanged -= SendScrolled; } if (Element != null) { TemplatedItemsView.TemplatedItems.CollectionChanged -= OnCollectionChanged; TemplatedItemsView.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged; } if (Control is object) { Control.SizeChanged -= Grid_SizeChanged; } _footerRenderer?.Dispose(); _headerRenderer?.Dispose(); } _isDisposed = true; base.Dispose(disposing); }
void RemovePage(Page page) { Fragment fragment = GetPageFragment(page); if (fragment == null) { return; } // Go ahead and take care of the fragment bookkeeping for the page being removed FragmentTransaction transaction = FragmentManager.BeginTransaction(); transaction.DisallowAddToBackStack(); transaction.Remove(fragment); transaction.CommitAllowingStateLoss(); FragmentManager.ExecutePendingTransactions(); // And remove the fragment from our own stack _fragmentStack.Remove(fragment); // Now handle all the XF removal/cleanup IVisualElementRenderer rendererToRemove = Android.Platform.GetRenderer(page); if (rendererToRemove != null) { var containerToRemove = (PageContainer)rendererToRemove.View.Parent; rendererToRemove.View?.RemoveFromParent(); rendererToRemove?.Dispose(); containerToRemove?.RemoveFromParent(); containerToRemove?.Dispose(); } Device.StartTimer(TimeSpan.FromMilliseconds(10), () => { UpdateToolbar(); return(false); }); }
protected override void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_view != null) { _view.MeasureInvalidated -= OnMeasureInvalidated; } _renderer?.Dispose(); _renderer = null; _view.ClearValue(Platform.RendererProperty); _disposed = true; } base.Dispose(disposing); }
void UpdateContent() { if (_renderer != null) { _renderer.View.RemoveFromParent(); _renderer.Dispose(); _renderer = null; } if (RefreshView.Content != null) { _renderer = Platform.CreateRenderer(RefreshView.Content, Context); Platform.SetRenderer(RefreshView.Content, _renderer); if (_renderer.View.Parent != null) { _renderer.View.RemoveFromParent(); } using (var layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)) SwipeRefreshLayout.AddView(_renderer.View, layoutParams); } }