Skip to content

Commit

Permalink
iOS: Updated project after changes to MobileNavigationManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Nov 1, 2013
1 parent 2c67a64 commit 73550d5
Show file tree
Hide file tree
Showing 44 changed files with 427 additions and 213 deletions.
6 changes: 6 additions & 0 deletions MPfm/MPfm.MVP/MPfm.MVP.iOS.csproj
Expand Up @@ -357,5 +357,11 @@
<Compile Include="Presenters\StartResumePlaybackPresenter.cs" />
<Compile Include="Presenters\Interfaces\IFirstRunPresenter.cs" />
<Compile Include="Presenters\Interfaces\IStartResumePlaybackPresenter.cs" />
<Compile Include="Navigation\INavigationManager.cs" />
<Compile Include="Views\IMobileMainView.cs" />
<Compile Include="Presenters\MobileMainPresenter.cs" />
<Compile Include="Presenters\Interfaces\IMobileMainPresenter.cs" />
<Compile Include="Messages\MobileLibraryBrowserChangeQueryMessage.cs" />
<Compile Include="Messages\MobileLibraryBrowserPopBackstackMessage.cs" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions MPfm/MPfm.MVP/Navigation/INavigationManager.cs
Expand Up @@ -63,16 +63,16 @@ public interface INavigationManager
void CreatePreferencesView();
void BindPreferencesView(IPreferencesView view);

IAudioPreferencesView CreateAudioPreferencesView();
void CreateAudioPreferencesView();
void BindAudioPreferencesView(IAudioPreferencesView view);

ICloudPreferencesView CreateCloudPreferencesView();
void CreateCloudPreferencesView();
void BindCloudPreferencesView(ICloudPreferencesView view);

IGeneralPreferencesView CreateGeneralPreferencesView();
void CreateGeneralPreferencesView();
void BindGeneralPreferencesView(IGeneralPreferencesView view);

ILibraryPreferencesView CreateLibraryPreferencesView();
void CreateLibraryPreferencesView();
void BindLibraryPreferencesView(ILibraryPreferencesView view);

IMobileLibraryBrowserView CreateMobileLibraryBrowserView(MobileNavigationTabType tabType, MobileLibraryBrowserType browserType, LibraryQuery query);
Expand Down
62 changes: 46 additions & 16 deletions MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -119,12 +119,13 @@ public abstract class MobileNavigationManager : INavigationManager
private IGeneralPreferencesPresenter _generalPreferencesPresenter;
private ILibraryPreferencesPresenter _libraryPreferencesPresenter;

//protected IPlaylistView PlaylistView { get { return _playlistView; } }
//protected IEqualizerPresetsView EqualizerPresetsView { get { return _equalizerPresetsView; } }
//protected IPlayerView PlayerView { get { return _playerView; } }
protected IPlaylistView PlaylistView { get { return _playlistView; } }
protected IEqualizerPresetsView EqualizerPresetsView { get { return _equalizerPresetsView; } }
protected IPlayerView PlayerView { get { return _playerView; } }

private readonly Dictionary<Tuple<MobileNavigationTabType, MobileLibraryBrowserType>, Tuple<IMobileLibraryBrowserView, IMobileLibraryBrowserPresenter>> _mobileLibraryBrowserList = new Dictionary<Tuple<MobileNavigationTabType, MobileLibraryBrowserType>, Tuple<IMobileLibraryBrowserView, IMobileLibraryBrowserPresenter>>();

public abstract void PushTabView(MobileNavigationTabType type, IBaseView view);
public abstract void PushDialogView(MobileDialogPresentationType presentationType, string viewTitle, IBaseView sourceView, IBaseView view);

public virtual void Start()
Expand All @@ -136,6 +137,11 @@ public virtual void Start()
private void ContinueAfterSplash()
{
AppConfigManager.Instance.Load();

#if IOS
CreateMobileMainView();
#endif

Tracing.Log("MobileNavigationManager - ContinueAfterSplash - isFirstRun: {0} resumePlayback.currentAudioFileId: {1} resumePlayback.currentPlaylistId: {2}", AppConfigManager.Instance.Root.IsFirstRun, AppConfigManager.Instance.Root.ResumePlayback.CurrentAudioFileId, AppConfigManager.Instance.Root.ResumePlayback.CurrentPlaylistId);
if (AppConfigManager.Instance.Root.IsFirstRun)
{
Expand All @@ -153,6 +159,7 @@ private void ContinueAfterSplash()
Tracing.Log("MobileNavigationManager - Resume playback is available; launching Player activity...");
var audioFiles = audioFileCacheService.AudioFiles.Where(x => x.ArtistName == audioFile.ArtistName && x.AlbumTitle == audioFile.AlbumTitle).ToList();
playerService.Play(audioFiles, audioFile.FilePath);
// TO DO: Start paused; resume playback when player view is ready.
CreatePlayerView(MobileNavigationTabType.Playlists);
}
}
Expand Down Expand Up @@ -278,7 +285,7 @@ public virtual void BindMobileMainView(IMobileMainView view)
_mainView.AddTab(MobileNavigationTabType.Artists, "Artists", MobileLibraryBrowserType.Artists, new LibraryQuery(), artistsView);
_mainView.AddTab(MobileNavigationTabType.Albums, "Albums", MobileLibraryBrowserType.Albums, new LibraryQuery(), albumsView);
_mainView.AddTab(MobileNavigationTabType.Songs, "Songs", MobileLibraryBrowserType.Songs, new LibraryQuery(), songsView);
_mainView.AddTab(MobileNavigationTabType.More, "More", moreView);
_mainView.AddTab(MobileNavigationTabType.More, "More", MobileLibraryBrowserType.Songs, new LibraryQuery(), moreView);
#endif
}

Expand Down Expand Up @@ -381,6 +388,8 @@ public virtual void CreatePreferencesView()
{
if(_preferencesView == null)
_preferencesView = Bootstrapper.GetContainer().Resolve<IPreferencesView>();

PushTabView(MobileNavigationTabType.More, _preferencesView);
}

public virtual void BindPreferencesView(IPreferencesView view)
Expand All @@ -406,10 +415,12 @@ public virtual void BindPreferencesView(IPreferencesView view)
#endif
}

public virtual IAudioPreferencesView CreateAudioPreferencesView()
public virtual void CreateAudioPreferencesView()
{
_audioPreferencesView = Bootstrapper.GetContainer().Resolve<IAudioPreferencesView>();
return _audioPreferencesView;
if(_audioPreferencesView == null)
_audioPreferencesView = Bootstrapper.GetContainer().Resolve<IAudioPreferencesView>();

PushTabView(MobileNavigationTabType.More, _audioPreferencesView);
}

public virtual void BindAudioPreferencesView(IAudioPreferencesView view)
Expand All @@ -425,10 +436,12 @@ public virtual void BindAudioPreferencesView(IAudioPreferencesView view)
};
}

public virtual ICloudPreferencesView CreateCloudPreferencesView()
public virtual void CreateCloudPreferencesView()
{
_cloudPreferencesView = Bootstrapper.GetContainer().Resolve<ICloudPreferencesView>();
return _cloudPreferencesView;
if(_cloudPreferencesView == null)
_cloudPreferencesView = Bootstrapper.GetContainer().Resolve<ICloudPreferencesView>();

PushTabView(MobileNavigationTabType.More, _cloudPreferencesView);
}

public virtual void BindCloudPreferencesView(ICloudPreferencesView view)
Expand All @@ -444,10 +457,12 @@ public virtual void BindCloudPreferencesView(ICloudPreferencesView view)
};
}

public virtual IGeneralPreferencesView CreateGeneralPreferencesView()
public virtual void CreateGeneralPreferencesView()
{
_generalPreferencesView = Bootstrapper.GetContainer().Resolve<IGeneralPreferencesView>();
return _generalPreferencesView;
if(_generalPreferencesView == null)
_generalPreferencesView = Bootstrapper.GetContainer().Resolve<IGeneralPreferencesView>();

PushTabView(MobileNavigationTabType.More, _generalPreferencesView);
}

public virtual void BindGeneralPreferencesView(IGeneralPreferencesView view)
Expand All @@ -463,10 +478,12 @@ public virtual void BindGeneralPreferencesView(IGeneralPreferencesView view)
};
}

public virtual ILibraryPreferencesView CreateLibraryPreferencesView()
public virtual void CreateLibraryPreferencesView()
{
_libraryPreferencesView = Bootstrapper.GetContainer().Resolve<ILibraryPreferencesView>();
return _libraryPreferencesView;
if(_libraryPreferencesView == null)
_libraryPreferencesView = Bootstrapper.GetContainer().Resolve<ILibraryPreferencesView>();

PushTabView(MobileNavigationTabType.More, _libraryPreferencesView);
}

public virtual void BindLibraryPreferencesView(ILibraryPreferencesView view)
Expand Down Expand Up @@ -527,6 +544,9 @@ public virtual void CreatePlayerView(MobileNavigationTabType tabType)
{
if (_playerView == null)
_playerView = Bootstrapper.GetContainer().Resolve<IPlayerView>();

// This is only used on iOS. Shouldn't this be routed to the main view? IMobileMainView.PushTabView?
PushTabView(tabType, _playerView);
}

public virtual void BindPlayerView(MobileNavigationTabType tabType, IPlayerView view)
Expand Down Expand Up @@ -731,6 +751,8 @@ public virtual void CreateSyncView()
{
if (_syncView == null)
_syncView = Bootstrapper.GetContainer().Resolve<ISyncView>();

PushTabView(MobileNavigationTabType.More, _syncView);
}

public virtual void BindSyncView(ISyncView view)
Expand All @@ -750,6 +772,8 @@ public virtual void CreateSyncWebBrowserView()
{
if (_syncWebBrowserView == null)
_syncWebBrowserView = Bootstrapper.GetContainer().Resolve<ISyncWebBrowserView>();

PushTabView(MobileNavigationTabType.More, _syncWebBrowserView);
}

public virtual void BindSyncWebBrowserView(ISyncWebBrowserView view)
Expand All @@ -769,6 +793,8 @@ public virtual void CreateSyncCloudView()
{
if (_syncCloudView == null)
_syncCloudView = Bootstrapper.GetContainer().Resolve<ISyncCloudView>();

PushTabView(MobileNavigationTabType.More, _syncCloudView);
}

public virtual void BindSyncCloudView(ISyncCloudView view)
Expand Down Expand Up @@ -840,6 +866,8 @@ public virtual void CreateAboutView()
{
if (_aboutView == null)
_aboutView = Bootstrapper.GetContainer().Resolve<IAboutView>();

PushTabView(MobileNavigationTabType.More, _aboutView);
}

public virtual void BindAboutView(IAboutView view)
Expand Down Expand Up @@ -878,6 +906,8 @@ public virtual void CreateResumePlaybackView()
{
if (_resumePlaybackView == null)
_resumePlaybackView = Bootstrapper.GetContainer().Resolve<IResumePlaybackView>();

PushTabView(MobileNavigationTabType.More, _resumePlaybackView);
}

public virtual void BindResumePlaybackView(IResumePlaybackView view)
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/MobileLibraryBrowserPresenter.cs
Expand Up @@ -323,7 +323,7 @@ private void ItemClick(int index)
SetQuery(browserType, _items[index].Query);
#else
var newView = _navigationManager.CreateMobileLibraryBrowserView(_tabType, browserType, _items[index].Query);
_navigationManager.PushTabView(_tabType, browserType, _items[index].Query, newView);
//_navigationManager.PushTabView(_tabType, browserType, _items[index].Query, newView);
#endif

return;
Expand Down
20 changes: 4 additions & 16 deletions MPfm/MPfm.MVP/Presenters/PreferencesPresenter.cs
Expand Up @@ -57,25 +57,13 @@ private void Initialize()
private void SelectItem(string item)
{
if(item.ToUpper() == "AUDIO PREFERENCES")
{
var view = _navigationManager.CreateAudioPreferencesView();
//_navigationManager.PushTabView(MobileNavigationTabType.More, view);
}
_navigationManager.CreateAudioPreferencesView();
else if(item.ToUpper() == "GENERAL PREFERENCES")
{
var view = _navigationManager.CreateGeneralPreferencesView();
//_navigationManager.PushTabView(MobileNavigationTabType.More, view);
}
_navigationManager.CreateGeneralPreferencesView();
else if(item.ToUpper() == "LIBRARY PREFERENCES")
{
var view = _navigationManager.CreateLibraryPreferencesView();
//_navigationManager.PushTabView(MobileNavigationTabType.More, view);
}
_navigationManager.CreateLibraryPreferencesView();
else if(item.ToUpper() == "CLOUD PREFERENCES")
{
var view = _navigationManager.CreateCloudPreferencesView();
//_navigationManager.PushTabView(MobileNavigationTabType.More, view);
}
_navigationManager.CreateCloudPreferencesView();
}
}
}
6 changes: 4 additions & 2 deletions MPfm/MPfm.MVP/Presenters/SplashPresenter.cs
Expand Up @@ -44,7 +44,8 @@ public async void Initialize(Action onInitDone)
{
if (_playerService.IsInitialized)
{
onInitDone.Invoke();
if(onInitDone != null)
onInitDone.Invoke();
return;
}

Expand All @@ -68,7 +69,8 @@ public async void Initialize(Action onInitDone)
};
_playerService.Initialize(device, 44100, 1000, 100);
View.InitDone(true);
onInitDone.Invoke();
if(onInitDone != null)
onInitDone.Invoke();
Console.WriteLine("SplashPresenter - Initialize - Initializing player on main thread... DONE!");
View.RefreshStatus("Opening app...");

Expand Down
9 changes: 7 additions & 2 deletions MPfm/MPfm.iOS/Classes/Controllers/AboutViewController.cs
Expand Up @@ -22,13 +22,15 @@
using MPfm.MVP.Views;
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;

namespace MPfm.iOS
{
public partial class AboutViewController : BaseViewController, IAboutView
{
public AboutViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "AboutViewController_iPhone" : "AboutViewController_iPad", null)
public AboutViewController()
: base (UserInterfaceIdiomIsPhone ? "AboutViewController_iPhone" : "AboutViewController_iPad", null)
{
}

Expand All @@ -38,6 +40,9 @@ public override void ViewDidLoad()
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
navigationManager.BindAboutView(this);
}

public override void ViewWillAppear(bool animated)
Expand Down
Expand Up @@ -21,13 +21,15 @@
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Views;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;

namespace MPfm.iOS
{
public partial class AddPlaylistViewController : BaseViewController, IAddPlaylistView
{
public AddPlaylistViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "AddPlaylistViewController_iPhone" : "AddPlaylistViewController_iPad", null)
public AddPlaylistViewController()
: base (UserInterfaceIdiomIsPhone ? "AddPlaylistViewController_iPhone" : "AddPlaylistViewController_iPad", null)
{
}

Expand All @@ -43,6 +45,9 @@ public override void ViewDidLoad()
btnCreate.SetImage(UIImage.FromBundle("Images/Buttons/select"));

base.ViewDidLoad();

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
navigationManager.BindAddPlaylistView(this);
}

private void CloseDialog()
Expand Down
Expand Up @@ -22,13 +22,15 @@
using MPfm.MVP.Views;
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;

namespace MPfm.iOS
{
public partial class AudioPreferencesViewController : BaseViewController, IAudioPreferencesView
{
public AudioPreferencesViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "AudioPreferencesViewController_iPhone" : "AudioPreferencesViewController_iPad", null)
public AudioPreferencesViewController()
: base (UserInterfaceIdiomIsPhone ? "AudioPreferencesViewController_iPhone" : "AudioPreferencesViewController_iPad", null)
{
}

Expand All @@ -38,6 +40,9 @@ public override void ViewDidLoad()
NavigationController.InteractivePopGestureRecognizer.Enabled = true;

base.ViewDidLoad();

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
navigationManager.BindAudioPreferencesView(this);
}

public override void ViewWillAppear(bool animated)
Expand Down
6 changes: 1 addition & 5 deletions MPfm/MPfm.iOS/Classes/Controllers/Base/BaseViewController.cs
Expand Up @@ -41,12 +41,9 @@ public void ShowView(bool shown)

#endregion

protected Action<IBaseView> OnViewReady { get; set; }

public BaseViewController(Action<IBaseView> onViewReady, string nibName, NSBundle bundle)
public BaseViewController(string nibName, NSBundle bundle)
: base(nibName, bundle)
{
OnViewReady = onViewReady;
}

public virtual void ConfirmedBackButton()
Expand Down Expand Up @@ -75,7 +72,6 @@ public override void ViewDidLoad()
EdgesForExtendedLayout = UIRectEdge.None;
base.ViewDidLoad();
this.NavigationItem.SetHidesBackButton(true, true);
OnViewReady(this);
}

public static bool UserInterfaceIdiomIsPhone
Expand Down
Expand Up @@ -23,19 +23,24 @@
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Config.Models;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;

namespace MPfm.iOS
{
public partial class CloudPreferencesViewController : BaseViewController, ICloudPreferencesView
{
public CloudPreferencesViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "CloudPreferencesViewController_iPhone" : "CloudPreferencesViewController_iPad", null)
public CloudPreferencesViewController()
: base (UserInterfaceIdiomIsPhone ? "CloudPreferencesViewController_iPhone" : "CloudPreferencesViewController_iPad", null)
{
}

public override void ViewDidLoad()
{
base.ViewDidLoad();

var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
navigationManager.BindCloudPreferencesView(this);
}

#region ICloudPreferencesView implementation
Expand Down

0 comments on commit 73550d5

Please sign in to comment.