Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed order of calls to properly close MediaPicker Activity / ViewController and set the picker result #21998

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Essentials/src/MediaPicker/MediaPicker.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public async Task<FileResult> PhotoAsync(MediaPickerOptions options, bool photo,
{
CompletedHandler = async info =>
{
GetFileResult(info, tcs);
await vc.DismissViewControllerAsync(true);
GetFileResult(info, tcs);
}
};

Expand Down
40 changes: 20 additions & 20 deletions src/Essentials/src/Platform/IntermediateActivity.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,32 @@ protected override void OnActivityResult(int requestCode, Result resultCode, Int
{
base.OnActivityResult(requestCode, resultCode, data);

// we have a valid GUID, so handle the task
if (GetIntermediateTask(guid, true) is IntermediateTask task)
var task = GetIntermediateTask(guid, true);

Finish();

if (task is null)
return;

if (resultCode == Result.Canceled)
{
task.TaskCompletionSource.TrySetCanceled();
}
else
{
if (resultCode == Result.Canceled)
try
{
task.TaskCompletionSource.TrySetCanceled();
data ??= new Intent();

task.OnResult?.Invoke(data);

task.TaskCompletionSource.TrySetResult(data);
}
else
catch (Exception ex)
{
try
{
data ??= new Intent();

task.OnResult?.Invoke(data);

task.TaskCompletionSource.TrySetResult(data);
}
catch (Exception ex)
{
task.TaskCompletionSource.TrySetException(ex);
}
task.TaskCompletionSource.TrySetException(ex);
}
}

// close the intermediate activity
Finish();
}

public static Task<Intent> StartAsync(Intent intent, int requestCode, Action<Intent>? onCreate = null, Action<Intent>? onResult = null)
Expand Down
Loading