Implement OnResume

develop
LEdoian 3 years ago
parent 3859437e7f
commit 0f074607fb

@ -25,15 +25,6 @@ namespace QuickPlay
appConfig = AppConfiguration.loadConfiguration(); appConfig = AppConfiguration.loadConfiguration();
var playerConfig = await appConfig.GetPlayerConfig(); var playerConfig = await appConfig.GetPlayerConfig();
currentPlayer = playerConfig.GetPlayer(); currentPlayer = playerConfig.GetPlayer();
try
{
await currentPlayer.ConnectAsync();
} catch (CannotConnectException e)
{
//TODO: View a toast with details and change some colors?
var t = Toast.MakeText(this, e.Message + ": " + e.InnerException.Message ?? "", ToastLength.Long);
t.Show();
}
// UI initialization // UI initialization
SetContentView(Resource.Layout.activity_main); SetContentView(Resource.Layout.activity_main);
@ -51,8 +42,7 @@ namespace QuickPlay
// Since this is rather complicated, it is in a separate method // Since this is rather complicated, it is in a separate method
InitializeRecyclerView(); InitializeRecyclerView();
// FIXME: This should be in OnResume... // I don't know why, but this needs to be here in order to show correct colors and player name.
// Refresh player info
OnPlayerUpdate(); OnPlayerUpdate();
} }
@ -135,5 +125,24 @@ namespace QuickPlay
{ {
await currentPlayer.Play(song); await currentPlayer.Play(song);
} }
public async void OnResume()
{
base.OnResume();
// Reconnect the player
try
{
await currentPlayer.ConnectAsync();
} catch (CannotConnectException e)
{
//TODO: View a toast with details and change some colors?
var t = Toast.MakeText(this, e.Message + ": " + e.InnerException.Message ?? "", ToastLength.Long);
t.Show();
}
// Refresh player info
OnPlayerUpdate();
}
} }
} }

Loading…
Cancel
Save