示例#1
0
 private void OnMvxIntentResultReceived(object sender, MvxIntentResultEventArgs e)
 {
     MvxTrace.Trace("OnMvxIntentResultReceived in MvxAndroidTask");
     // TODO - is this correct - should we always remove the result registration even if this isn't necessarily our result?
     Mvx.Resolve<IMvxIntentResultSource>().Result -= this.OnMvxIntentResultReceived;
     this.ProcessMvxIntentResult(e);
 }
示例#2
0
 protected override void EventSourceOnActivityResultCalled(object sender,
                                                           MvxValueEventArgs<MvxActivityResultParameters>
                                                               args)
 {
     var sink = Mvx.Resolve<IMvxIntentResultSink>();
     var resultParameters = args.Value;
     var intentResult = new MvxIntentResultEventArgs(resultParameters.RequestCode, resultParameters.ResultCode,
                                                     resultParameters.Data);
     sink.OnResult(intentResult);
 }
 public void OnResult(MvxIntentResultEventArgs result)
 {
     Result?.Invoke(this, result);
 }
        private void ProcessPictureUri(MvxIntentResultEventArgs result, Uri uri)
        {
            if (_currentRequestParameters == null)
            {
                MvxTrace.Error("Internal error - response received but _currentRequestParameters is null");
                return; // we have not handled this - so we return null
            }

            var responseSent = false;
            try
            {
                // Note for furture bug-fixing/maintenance - it might be better to use var outputFileUri = data.GetParcelableArrayExtra("outputFileuri") here?
                if (result.ResultCode != Result.Ok)
                {
                    MvxTrace.Trace("Non-OK result received from MvxIntentResult - {0} - request was {1}",
                                   result.ResultCode, result.RequestCode);
                    return;
                }

                if (string.IsNullOrEmpty(uri?.Path))
                {
                    MvxTrace.Trace("Empty uri or file path received for MvxIntentResult");
                    return;
                }

                MvxTrace.Trace("Loading InMemoryBitmap started...");
                var memoryStream = LoadInMemoryBitmap(uri);
                if (memoryStream == null)
                {
                    MvxTrace.Trace("Loading InMemoryBitmap failed...");
                    return;
                }
                MvxTrace.Trace("Loading InMemoryBitmap complete...");
                responseSent = true;
                MvxTrace.Trace("Sending pictureAvailable...");
                _currentRequestParameters.PictureAvailable(memoryStream);
                MvxTrace.Trace("pictureAvailable completed...");
                return;
            }
            finally
            {
                if (!responseSent)
                    _currentRequestParameters.AssumeCancelled();

                _currentRequestParameters = null;
            }
        }
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            MvxTrace.Trace("ProcessMvxIntentResult started...");

            Uri uri;

            switch ((MvxIntentRequestCode) result.RequestCode)
            {
                case MvxIntentRequestCode.PickFromFile:
                    uri = result.Data?.Data;
                    break;
                case MvxIntentRequestCode.PickFromCamera:
                    uri = _cachedUriLocation;
                    break;
                default:
                    // ignore this result - it's not for us
                    MvxTrace.Trace("Unexpected request received from MvxIntentResult - request was {0}",
                                   result.RequestCode);
                    return;
            }

            ProcessPictureUri(result, uri);
        }
示例#6
0
 protected virtual void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
 {
     // default processing does nothing
 }