Skip to content
Merged
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
40 changes: 32 additions & 8 deletions Float.TinCan.ActivityLibrary/ActivityLaunchCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Float.Core.UI;
using Float.Core.UX;
using Float.FileDownloader;
Expand Down Expand Up @@ -110,7 +111,7 @@ public override void Start()
}
else
{
Device.BeginInvokeOnMainThread(() =>
Device.BeginInvokeOnMainThread(async () =>
{
try
{
Expand All @@ -127,8 +128,7 @@ public override void Start()

downloadStatus.DownloadsCompleted += HandleDownloadCompleted;
downloadStatus.DownloadsCancelled += HandleDownloadCancelled;

NavigationContext.PresentPage(CreateDownloadStatusPage(downloadStatus));
await ShowDownloadStatus(CreateDownloadStatusPage(downloadStatus));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EBusch Could we get into a state where we are creating/presenting the download page more than once?
just wondering if we need a protection from creating multiple

});
}
}
Expand All @@ -138,7 +138,31 @@ public override void Start()
/// </summary>
/// <returns>The download status page.</returns>
/// <param name="downloadStatus">Download status.</param>
protected abstract BaseContentPage CreateDownloadStatusPage(DownloadStatus downloadStatus);
protected abstract ContentPage CreateDownloadStatusPage(DownloadStatus downloadStatus);

/// <summary>
/// Shows the download status page.
/// </summary>
/// <param name="downloadStatusPage">The download status page.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
protected virtual async Task ShowDownloadStatus(ContentPage downloadStatusPage)
{
if (downloadStatusPage is null)
{
throw new ArgumentNullException(nameof(downloadStatusPage));
}

await NavigationContext.PresentPageAsync(downloadStatusPage);
}

/// <summary>
/// Dismisses the download status page.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
protected virtual async Task DismissDownloadStatus()
{
await NavigationContext.PopPageAsync();
}

/// <summary>
/// Creates the activity complete page.
Expand Down Expand Up @@ -341,8 +365,7 @@ protected virtual async void HandleDownloadCompleted(object sender, EventArgs ar

startLocation = Activity.MetaData.StartLocation;
isCreatingRunner = true;

await NavigationContext.DismissPageAsync();
await DismissDownloadStatus();

CreateRunnerAndHandleErrors();

Expand All @@ -360,15 +383,16 @@ protected virtual async void HandleDownloadCompleted(object sender, EventArgs ar
/// </summary>
/// <param name="sender">The sending object.</param>
/// <param name="args">Arguments related to the event.</param>
protected virtual void HandleDownloadCancelled(object sender, EventArgs args)
protected virtual async void HandleDownloadCancelled(object sender, EventArgs args)
{
if (downloadStatus != null)
{
downloadStatus.DownloadsCompleted -= HandleDownloadCompleted;
downloadStatus.DownloadsCancelled -= HandleDownloadCancelled;
}

NavigationContext.DismissPage();
await DismissDownloadStatus();

downloadStatus = null;
}

Expand Down