diff --git a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs index 2ad0cf0d..454c5702 100644 --- a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs +++ b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs @@ -297,7 +297,9 @@ public void ShowSplash(SplashFragment fragment) public void HideSplash() { //Console.WriteLine("MainActivity - HideSplash"); - _splashFragment.Dialog.Dismiss(); + + if(_splashFragment.Dialog != null) + _splashFragment.Dialog.Dismiss(); } #region IMobileOptionsMenuView implementation diff --git a/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs b/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs index 3a4b0d8e..712c8bc3 100644 --- a/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs +++ b/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs @@ -213,16 +213,18 @@ public void RefreshLibraryBrowser(IEnumerable entities, Mo _listView.Visibility = ViewStates.Visible; _gridView.Visibility = ViewStates.Gone; - var audioFile = _entities[0].AudioFile; - _lblArtistName.Text = audioFile.ArtistName; - _lblAlbumTitle.Text = audioFile.AlbumTitle; - _lblAlbumSongCount.Text = _entities.Count.ToString() + " songs"; - - Task.Factory.StartNew(() => + if (_entities.Count > 0) { - byte[] bytesImage = AudioFile.ExtractImageByteArrayForAudioFile(audioFile.FilePath); - _bitmapCache.LoadBitmapFromByteArray(bytesImage, audioFile.FilePath, _imageAlbum); - }); + var audioFile = _entities[0].AudioFile; + _lblArtistName.Text = audioFile.ArtistName; + _lblAlbumTitle.Text = audioFile.AlbumTitle; + _lblAlbumSongCount.Text = _entities.Count.ToString() + " songs"; + + Task.Factory.StartNew(() => { + byte[] bytesImage = AudioFile.ExtractImageByteArrayForAudioFile(audioFile.FilePath); + _bitmapCache.LoadBitmapFromByteArray(bytesImage, audioFile.FilePath, _imageAlbum); + }); + } break; case MobileLibraryBrowserType.Playlists: _layoutAlbum.Visibility = ViewStates.Gone; diff --git a/MPfm/MPfm.Android/Classes/Fragments/SplashFragment.cs b/MPfm/MPfm.Android/Classes/Fragments/SplashFragment.cs index d67b3069..b75413cf 100644 --- a/MPfm/MPfm.Android/Classes/Fragments/SplashFragment.cs +++ b/MPfm/MPfm.Android/Classes/Fragments/SplashFragment.cs @@ -70,9 +70,8 @@ public void RefreshStatus(string message) }); } - public void InitDone() + public void InitDone(bool isFirstAppStart) { - //this.Dismiss(); } #endregion diff --git a/MPfm/MPfm.Android/Resources/Resource.Designer.cs b/MPfm/MPfm.Android/Resources/Resource.Designer.cs index 5f09ddb2..87a5fdaf 100644 --- a/MPfm/MPfm.Android/Resources/Resource.Designer.cs +++ b/MPfm/MPfm.Android/Resources/Resource.Designer.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18052 +// Runtime Version:4.0.30319.18213 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/MPfm/MPfm.MVP/Presenters/SplashPresenter.cs b/MPfm/MPfm.MVP/Presenters/SplashPresenter.cs index 6e8c38c0..7c6dbf45 100644 --- a/MPfm/MPfm.MVP/Presenters/SplashPresenter.cs +++ b/MPfm/MPfm.MVP/Presenters/SplashPresenter.cs @@ -40,12 +40,17 @@ public SplashPresenter(IInitializationService initializationService, IPlayerServ public void Initialize(Action onInitDone) { + if (_playerService.IsInitialized) + { + onInitDone.Invoke(); + return; + } + TaskScheduler taskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); #if LINUX // Mono on Linux crashes for some reason if FromCurrentSynchronizationContext is used... weird! taskScheduler = TaskScheduler.Default; #endif - Task.Factory.StartNew(() => { View.RefreshStatus("Loading..."); @@ -58,7 +63,7 @@ public void Initialize(Action onInitDone) Id = -1 }; _playerService.Initialize(device, 44100, 1000, 100); - View.InitDone(); + View.InitDone(true); onInitDone.Invoke(); View.RefreshStatus("Opening app..."); }, taskScheduler); diff --git a/MPfm/MPfm.MVP/Services/Interfaces/IPlayerService.cs b/MPfm/MPfm.MVP/Services/Interfaces/IPlayerService.cs index 4ddfc0e0..642efab4 100644 --- a/MPfm/MPfm.MVP/Services/Interfaces/IPlayerService.cs +++ b/MPfm/MPfm.MVP/Services/Interfaces/IPlayerService.cs @@ -30,6 +30,7 @@ namespace MPfm.MVP.Services.Interfaces /// public interface IPlayerService { + bool IsInitialized { get; } bool IsSettingPosition { get; } bool IsPlaying { get; } bool IsPaused { get; } diff --git a/MPfm/MPfm.MVP/Services/PlayerService.cs b/MPfm/MPfm.MVP/Services/PlayerService.cs index bbeb72e8..a66a5f33 100644 --- a/MPfm/MPfm.MVP/Services/PlayerService.cs +++ b/MPfm/MPfm.MVP/Services/PlayerService.cs @@ -39,6 +39,7 @@ public class PlayerService : IPlayerService private IPlayer _player; private PlayerStatusType _status; + public bool IsInitialized { get; private set; } public bool IsSettingPosition { get { return _player.IsSettingPosition; } } public bool IsPlaying { get { return _player.IsPlaying; } } public bool IsPaused { get { return _player.IsPaused; } } @@ -69,6 +70,7 @@ public void Initialize(Device device, int sampleRate, int bufferSize, int update _player.OnAudioInterrupted += HandleOnAudioInterrupted; _player.OnBPMDetected += HandleOnBPMDetected; _messengerHub.Subscribe(PlayerCommandMessageReceived); + IsInitialized = true; } void HandleOnBPMDetected(float bpm) diff --git a/MPfm/MPfm.MVP/Views/ISplashView.cs b/MPfm/MPfm.MVP/Views/ISplashView.cs index 48728c27..6935de9f 100644 --- a/MPfm/MPfm.MVP/Views/ISplashView.cs +++ b/MPfm/MPfm.MVP/Views/ISplashView.cs @@ -22,9 +22,7 @@ namespace MPfm.MVP.Views /// public interface ISplashView : IBaseView { - //Action OnViewReady { get; set; } - void RefreshStatus(string message); - void InitDone(); + void InitDone(bool isAppFirstStart); } } diff --git a/MPfm/MPfm.Sound/BassNetKey.cs b/MPfm/MPfm.Sound/BassNetKey.cs index 2a25cc8a..79da639b 100644 --- a/MPfm/MPfm.Sound/BassNetKey.cs +++ b/MPfm/MPfm.Sound/BassNetKey.cs @@ -2,11 +2,11 @@ // To build MPfm correctly, you need to generate your own BASS.NET key at this website: http://bass.radio42.com/bass_register.html // Simply uncomment this file and add your email/key. -//namespace MPfm.Sound -//{ -// public static class BassNetKey -// { -// public const string Email = ""; -// public const string RegistrationKey = ""; -// } -//} \ No newline at end of file +namespace MPfm.Sound +{ + public static class BassNetKey + { + public const string Email = "yanick.castonguay@gmail.com"; + public const string RegistrationKey = "2X3433427152222"; + } +} \ No newline at end of file diff --git a/MPfm/MPfm.Sound/MPfm.Sound.Android.csproj b/MPfm/MPfm.Sound/MPfm.Sound.Android.csproj index 8b3381a6..2ed0df46 100644 --- a/MPfm/MPfm.Sound/MPfm.Sound.Android.csproj +++ b/MPfm/MPfm.Sound/MPfm.Sound.Android.csproj @@ -150,7 +150,6 @@ -