// this is called on any error while processing the document image
        // Note: this is called every time an error occurs in a run, so that might be quite often
        // An error message should only be presented to the user after some time
        void IDocumentResultListener.OnPreviewProcessingFailure(DocumentScanView.DocumentError error)
        {
            if (_toast != null)
            {
                _toast.Cancel();
            }

            var    e    = error.ToString();
            string text = "";

            if (e.Equals(DocumentScanView.DocumentError.DocumentNotSharp.ToString()))
            {
                text += "Document is not sharp. Please hold the camera steadily and ensure the document is in focus.";
            }
            if (e.Equals(DocumentScanView.DocumentError.DocumentSkewTooHigh.ToString()))
            {
                text += "Document is skewed. Place the camera directly above the document.";
            }
            if (e.Equals(DocumentScanView.DocumentError.DocumentOutlineNotFound.ToString()))
            {
                text += "Could not detect document outline.";
            }
            if (e.Equals(DocumentScanView.DocumentError.GlareDetected.ToString()))
            {
                text += "Please remove the glare.";
            }
            if (e.Equals(DocumentScanView.DocumentError.ImageTooDark.ToString()))
            {
                text += "The image is too dark. Please ensure there is enough light.";
            }
            if (e.Equals(DocumentScanView.DocumentError.Unknown.ToString()))
            {
                text += "Unknown Failure.";
            }

            if (text != "")
            {
                _toast = Toast.MakeText(this, text, ToastLength.Short);
                _toast.Show();
            }
        }
        // handle an error while processing the full picture here - the preview will be restarted automatically
        void IDocumentResultListener.OnPictureProcessingFailure(DocumentScanView.DocumentError error)
        {
            String text = "Error scanning full document. ";
            String e    = error.ToString();

            if (e.Equals(DocumentScanView.DocumentError.DocumentNotSharp.ToString()))
            {
                text += "Document is not sharp. Please hold the camera steadily and ensure the document is in focus.";
            }
            if (e.Equals(DocumentScanView.DocumentError.DocumentSkewTooHigh.ToString()))
            {
                text += "Document is skewed. Place the camera directly above the document.";
            }
            if (e.Equals(DocumentScanView.DocumentError.DocumentOutlineNotFound.ToString()))
            {
                text += "Could not detect document outline.";
            }
            if (e.Equals(DocumentScanView.DocumentError.GlareDetected.ToString()))
            {
                text += "Please remove the glare.";
            }
            if (e.Equals(DocumentScanView.DocumentError.ImageTooDark.ToString()))
            {
                text += "The image is too dark. Please ensure there is enough light.";
            }
            if (e.Equals(DocumentScanView.DocumentError.Unknown.ToString()))
            {
                text += "Unknown Failure.";
            }

            _toast = Toast.MakeText(this, text, ToastLength.Long);
            _toast.Show();

            if (_progressDialog != null && _progressDialog.IsShowing)
            {
                _progressDialog.Dismiss();
            }

            _imageViewFull.SetImageBitmap(null);
        }