示例#1
0
        protected override IParcelable OnSaveInstanceState()
        {
            var state = base.OnSaveInstanceState();

            var savedState = new SavedImageState(state)
            {
                Json = JsonConvert.SerializeObject(Strokes)
            };

            imageView.SetImageBitmap(null);
            imageView = null;

            drawingImageView.SetImageBitmap(null);
            drawingImageView = null;

            image.Recycle();
            image.Dispose();
            image = null;

            drawingImage.Recycle();
            drawingImage.Dispose();
            drawingImage = null;

            canvas.Dispose();
            canvas = null;

            drawingCanvas.Dispose();
            drawingCanvas = null;

            GC.Collect();

            return(savedState);
        }
示例#2
0
        protected override IParcelable OnSaveInstanceState()
        {
            var state = base.OnSaveInstanceState();

            if (Strokes == null)
            {
                Strokes = new List <Abstractions.Stroke>();
            }

            SavedImageState savedState = null;

            if (state != null)
            {
                savedState = new SavedImageState(state)
                {
                    Json = JsonConvert.SerializeObject(Strokes)
                };
            }

            if (imageView != null)
            {
                imageView.SetImageBitmap(null);
                imageView = null;
            }

            if (drawingImageView != null)
            {
                drawingImageView.SetImageBitmap(null);
                drawingImageView = null;
            }

            if (image != null)
            {
                image.Recycle();
                image.Dispose();
                image = null;
            }

            if (drawingImage != null)
            {
                drawingImage.Recycle();
                drawingImage.Dispose();
                drawingImage = null;
            }

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

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

            GC.Collect();

            return(savedState);
        }