Make cfgProviders asynchronous

(in a quite bad ways sometimes...)
develop
LEdoian 3 years ago
parent eb7d1dda65
commit 8d1dffc743

@ -77,7 +77,7 @@ namespace QuickPlay
{
// TODO: decide sensibly
var cfgProvider = new HttpConfigurationProvider(playerConfigUrl);
return cfgProvider.GetConfiguration();
return cfgProvider.GetConfigurationAsync().Result; // Bad code, but hopefully we dont hang.
}
// We want to compare by values.
@ -131,7 +131,7 @@ namespace QuickPlay
interface IPlayerConfigurationProvider
{
PlayerConfiguration GetConfiguration();
Task<PlayerConfiguration> GetConfigurationAsync();
}
sealed class HttpConfigurationProvider : IPlayerConfigurationProvider
@ -141,7 +141,7 @@ namespace QuickPlay
{
configUrl = url;
}
public async Task<PlayerConfiguration> GetConfiguration()
public async Task<PlayerConfiguration> GetConfigurationAsync()
{
var client = new HttpClient() ;
var resp = await client.GetStreamAsync(configUrl);
@ -162,15 +162,15 @@ namespace QuickPlay
{
this.reader = new StreamReader(filename);
}
public PlayerConfiguration GetConfiguration()
public Task<PlayerConfiguration> GetConfigurationAsync()
{
return PlayerConfiguration.FromFile(reader);
return Task.FromResult(PlayerConfiguration.FromFile(reader));
}
}
sealed class DummyConfigurationProvider : IPlayerConfigurationProvider
{
public PlayerConfiguration GetConfiguration() => null;
public Task<PlayerConfiguration> GetConfigurationAsync() => null;
}
class Song: IPlayable

@ -60,6 +60,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
@ -68,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="IniParser.cs" />
<Compile Include="Interfaces.cs" />
<Compile Include="MpdMonitorService.cs" />
<Compile Include="MainActivity.cs" />

Loading…
Cancel
Save