Override Import() instead.

This commit is contained in:
Lucas A 2020-12-08 19:46:55 +01:00
parent d8838ddbfb
commit aa7d22460d
4 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Threading.Tasks;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using Android.Content.PM; using Android.Content.PM;
@ -57,7 +58,7 @@ namespace osu.Android
var stream = ContentResolver.OpenInputStream(uri); var stream = ContentResolver.OpenInputStream(uri);
if (stream != null) if (stream != null)
game.ScheduleImport(stream, cursor.GetString(filename_column)); Task.Factory.StartNew(() => game.Import(stream, cursor.GetString(filename_column)), TaskCreationOptions.LongRunning);
} }
} }
} }

View File

@ -67,12 +67,11 @@ namespace osu.Android
} }
} }
/// <summary> public override Task Import(Stream stream, string filename)
/// Schedules a file to be imported once the game is loaded. {
/// </summary> WaitForReady(() => this, _ => Task.Run(() => base.Import(stream, filename)));
/// <param name="stream">A stream to the file to import.</param> return Task.CompletedTask;
/// <param name="filename">The filename of the file to import.</param> }
public void ScheduleImport(Stream stream, string filename) => WaitForReady(() => this, _ => Task.Run(() => Import(stream, filename)));
protected override void LoadComplete() protected override void LoadComplete()
{ {

View File

@ -218,7 +218,7 @@ namespace osu.Game.Database
} }
return import; return import;
} }
/// <summary> /// <summary>
/// Fired when the user requests to view the resulting import. /// Fired when the user requests to view the resulting import.

View File

@ -395,7 +395,7 @@ namespace osu.Game
} }
} }
public async Task Import(Stream stream, string filename) public virtual async Task Import(Stream stream, string filename)
{ {
var extension = Path.GetExtension(filename)?.ToLowerInvariant(); var extension = Path.GetExtension(filename)?.ToLowerInvariant();