Beispiel #1
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            //don't clean up objects, if we want the controller to be kept alive
            if (keepScanViewControllerAlive)
            {
                return;
            }

            //we have to un-register the event handlers because else the whole viewcontroller will be kept in the garbage collector.
            if (meterTypeSegment != null)
            {
                meterTypeSegment.ValueChanged -= HandleSegmentChange;
            }

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

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

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

            segmentItems = null;

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

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

            //we have to erase the scan view so that there are no dependencies for the viewcontroller left.
            anylineEnergyView.RemoveFromSuperview();
            anylineEnergyView.Dispose();
            anylineEnergyView = null;

            base.Dispose();
        }
Beispiel #2
0
        private void Save(string path, int size, Action <bool> callback, NSDictionary data)
        {
            bool result = false;

            UIImage photo  = null;
            UIImage source = null;
            NSData  file   = null;
            NSError error  = null;

            try
            {
                source = data.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                if (source != null)
                {
                    photo = ScaleImage(source, size);
                    file  = photo.AsJPEG();
                    bool saved = file.Save(path, false, out error);
                    if (!saved)
                    {
                        Context.HandleException(new NonFatalException(D.IO_EXCEPTION, error.LocalizedDescription));
                    }
                    result = saved;
                }
            }
            finally
            {
                if (photo != null)
                {
                    photo.Dispose();
                }
                if (source != null)
                {
                    source.Dispose();
                }
                if (file != null)
                {
                    file.Dispose();
                }
                if (error != null)
                {
                    error.Dispose();
                }
                if (data != null)
                {
                    data.Dispose();
                }
            }

            Task.Run(() =>
            {
                Thread.Sleep(300);
                Context.InvokeOnMainThread(() => callback(result));
            });
        }
        /// <summary>
        /// Determines if the path is a symbolic link, iOS style.
        /// </summary>
        protected override bool IsSymLink(string path)
        {
            NSError error = null;

            try
            {
                var attributes = NSFileManager.DefaultManager?.GetAttributes(path, out error);
                if (attributes == null || error != null)
                {
                    return(false);
                }

                return(attributes.Type == NSFileType.SymbolicLink);
            }
            finally
            {
                error?.Dispose();
            }
        }
        new void Dispose()
        {
            //we have to un-register the event handlers because else the whole viewcontroller will be kept in the garbage collector.
            if (_meterTypeSegment != null)
            {
                _meterTypeSegment.ValueChanged -= HandleSegmentChange;
            }

            _meterTypeSegment?.Dispose();

            _selectionLabel?.Dispose();

            _toggleBarcodeLabel.RemoveFromSuperview();
            _toggleBarcodeLabel?.Dispose();

            _toggleBarcodeSwitch.ValueChanged -= OnValueChanged;
            _toggleBarcodeSwitch.RemoveFromSuperview();
            _toggleBarcodeSwitch?.Dispose();

            _toggleBarcodeView.RemoveFromSuperview();
            _toggleBarcodeView?.Dispose();

            _segmentItems = null;

            _alert?.Dispose();
            _error?.Dispose();

            //we have to erase the scan view so that there are no dependencies for the viewcontroller left.
            _anylineEnergyView?.RemoveFromSuperview();
            _anylineEnergyView?.Dispose();
            _anylineEnergyView = null;

            GC.Collect(GC.MaxGeneration);

            base.Dispose();
        }
Beispiel #5
0
    public void NewObjectDispose()
    {
        var obj = new NSError("com.hitcents.ios4unity", 122);

        obj.Dispose();
    }