Ejemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (CheckFlagsForDisposed())
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                EffectUtilities.UnregisterEffectControlProvider(this, Element);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_gestureManager != null)
                {
                    _gestureManager.Dispose();
                    _gestureManager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                RemoveAllViews();

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_scaleDetector != null && _scaleDetector.IsValueCreated)
                {
                    _scaleDetector.Value.Dispose();
                    _scaleDetector = null;
                }

                if (_gestureListener != null)
                {
                    _gestureListener.Dispose();
                    _gestureListener = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                RemoveAllViews();

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;
                    UnsubscribeGestureRecognizers(Element);

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }