Hide context to the environment

develop
LEdoian 3 years ago
parent a5edd77760
commit 71abb3fcd8

@ -25,11 +25,8 @@ namespace QuickPlay
/// Since this operation can be asynchronous, we cannot put it in th
/// constructor. And this allows for some tweaks before connecting.
/// </summary>
/// <param name="context">
/// Context to run possible services from.
/// </param>
/// <returns></returns>
Task ConnectAsync(Context context);
Task ConnectAsync();
}
/// <summary>
/// A simple dataclass to hold auxiliary data of the Playable objects.

@ -40,7 +40,7 @@ namespace QuickPlay
currentPlayer = playerConfig.GetPlayer();
try
{
await currentPlayer.ConnectAsync(this);
await currentPlayer.ConnectAsync();
} catch (CannotConnectException e)
{
//TODO: View a toast with details and change some colors?

@ -17,6 +17,7 @@ namespace QuickPlay
public override void OnCreate()
{
base.OnCreate();
// TODO: Create the watching thread
}
public override IBinder OnBind(Intent intent)
{

@ -16,7 +16,6 @@ namespace QuickPlay
class MpdPlayer: IPlayer
{
MpcCoreClient mpd;
Thread serviceThread;
// MpcCore uses strings, so be it
string mpdIP, mpdPort;
@ -49,7 +48,7 @@ namespace QuickPlay
mpdPort = connDetails.Length >=2 ? connDetails[1] : "6600"; // XXX: Unneccessary default here...
// Connecting and monitoring remote player is done in ConnectAsync.
}
public async Task ConnectAsync(Context ctx)
public async Task ConnectAsync()
{
// Create a persistent connection
var conn = new MpcCoreConnection(mpdIP, mpdPort);
@ -62,12 +61,8 @@ namespace QuickPlay
throw new CannotConnectException("MPD connect failed", e);
}
// Start the monitoring service
Console.WriteLine("Hello! Will run thr.");
serviceThread = new Thread(() =>
{
var ctx = Android.App.Application.Context;
var intent = new Intent(ctx, typeof(MpdMonitorService));
});
Console.WriteLine("Thread possibly started");
}
}
}
Loading…
Cancel
Save