Navigation Menu

Skip to content

Commit

Permalink
iOS: Updated project after changes on other platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Oct 15, 2013
2 parents bf710fb + 7c8c636 commit 49ee2cc
Show file tree
Hide file tree
Showing 62 changed files with 1,435 additions and 1,257 deletions.
Expand Up @@ -122,7 +122,7 @@ public override View GetView(int position, View convertView, ViewGroup parent)
lblSubtitle.Text = item.AudioFile.Length;
}

switch (item.Type)
switch (item.EntityType)
{
case LibraryBrowserEntityType.Song:
layoutAlbums.Visibility = ViewStates.Gone;
Expand Down
3 changes: 3 additions & 0 deletions MPfm/MPfm.Android/Classes/Application.cs
Expand Up @@ -22,9 +22,11 @@
using Android.Runtime;
using MPfm.Android.Classes.Fragments;
using MPfm.Android.Classes.Navigation;
using MPfm.Android.Classes.Providers;
using MPfm.Android.Classes.Receivers;
using MPfm.Library;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Config.Providers;
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;
using MPfm.Android.Classes.Services;
Expand Down Expand Up @@ -149,6 +151,7 @@ private void BootstrapApp()
// Complete IoC configuration
TinyIoC.TinyIoCContainer container = Bootstrapper.GetContainer();
container.Register<ISyncDeviceSpecifications, AndroidSyncDeviceSpecifications>().AsSingleton();
container.Register<IAppConfigProvider, AndroidAppConfigProvider>().AsSingleton();
container.Register<MobileNavigationManager, AndroidNavigationManager>().AsSingleton();
container.Register<IMobileOptionsMenuView, MainActivity>().AsMultiInstance();
container.Register<ISplashView, SplashFragment>().AsMultiInstance();
Expand Down
Expand Up @@ -58,7 +58,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
public Action OnToggleShuffle { get; set; }
public Action OnToggleRepeat { get; set; }

public void RefreshAudioFile(AudioFile audioFile)
public void RefreshMetadata(AudioFile audioFile, int playlistIndex, int playlistCount)
{
Activity.RunOnUiThread(() => {
if (audioFile != null)
Expand Down
Expand Up @@ -177,12 +177,12 @@ public override void PushTabView(MobileNavigationTabType type, MobileLibraryBrow
// Not used on Android
}

public override void PushDialogView(string viewTitle, IBaseView sourceView, IBaseView view)
public override void PushDialogView(MobileDialogPresentationType presentationType, string viewTitle, IBaseView sourceView, IBaseView view)
{
MainActivity.PushDialogView(viewTitle, sourceView, view);
}

public override void PushDialogSubview(string parentViewTitle, IBaseView view)
public override void PushDialogSubview(MobileDialogPresentationType presentationType, string parentViewTitle, IBaseView view)
{
MainActivity.PushDialogSubview(parentViewTitle, view);
}
Expand Down
34 changes: 34 additions & 0 deletions MPfm/MPfm.Android/Classes/Providers/AndroidAppConfigProvider.cs
@@ -0,0 +1,34 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using MPfm.MVP.Config;
using MPfm.MVP.Config.Providers;

namespace MPfm.Android.Classes.Providers
{
public class AndroidAppConfigProvider : IAppConfigProvider
{
public RootAppConfig Load(string filePath)
{
return new RootAppConfig();
}

public void Save(string filePath, RootAppConfig config)
{
}
}
}
1 change: 1 addition & 0 deletions MPfm/MPfm.Android/MPfm.Android.csproj
Expand Up @@ -129,6 +129,7 @@
<Compile Include="Classes\Managers\Events\GeneratePeakFileEventArgs.cs" />
<Compile Include="Classes\Managers\WaveFormCacheManager.cs" />
<Compile Include="Classes\Navigation\AndroidNavigationManager.cs" />
<Compile Include="Classes\Providers\AndroidAppConfigProvider.cs" />
<Compile Include="Classes\Receivers\ConnectionChangeReceiver.cs" />
<Compile Include="Classes\Receivers\LockReceiver.cs" />
<Compile Include="Classes\Receivers\WifiDirectReceiver.cs" />
Expand Down
116 changes: 19 additions & 97 deletions MPfm/MPfm.Library/Database/WinRTSQLiteGateway.cs
Expand Up @@ -64,7 +64,7 @@ public WinRTSQLiteGateway(string databaseFilePath)
/// </summary>
public static void CreateDatabaseFile(string databaseFilePath)
{
// Not available on WinRT... the database needs to already exist!
// Just create a connection, if the file doesn't exist, it will create the file.
}

/// <summary>
Expand Down Expand Up @@ -348,108 +348,30 @@ public T SelectOne<T>(string sql) where T : new()
public List<T> Select<T>(string sql) where T : new()
{
SQLiteConnection connection = null;
//DbDataReader reader = null;
SQLiteCommand command = null;
List<T> list = new List<T>();
var maps = GetMap<T>();

return list;

//try
//{
// // Create and open _connection
// connection = GenerateConnection();
// connection.Open();

// // Create command
// command = factory.CreateCommand();
// command.CommandText = sql;
// command.Connection = connection;

// // Create and execute reader
// reader = command.ExecuteReader();
// while (reader.Read())
// {
// // Create object and fill data
// T data = new T();

// // Cycle through columns
// for (int a = 0; a < reader.FieldCount; a++)
// {
// // Get column info
// string fieldName = reader.GetName(a);
// Type fieldType = reader.GetFieldType(a);
// object fieldValue = reader.GetValue(a);

// // Check for map
// string propertyName = fieldName;
// if(dictMap.ContainsKey(fieldName))
// {
// propertyName = dictMap[fieldName];
// }

// // Get property info and fill column if valid
// PropertyInfo info = typeof(T).GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);
// if (info != null)
// {
// // Set value to null
// if (fieldValue is System.DBNull)
// fieldValue = null;

// // Check if the type is an enum
// if (info.PropertyType.IsEnum)
// {
// fieldValue = Enum.Parse(info.PropertyType, fieldValue.ToString());
// }
// else if (info.PropertyType.FullName.ToUpper() == "SYSTEM.GUID")
// {
// // Guid aren't supported in SQLite, so they are stored as strings.
// fieldValue = new Guid(fieldValue.ToString());
// }
// else if (info.PropertyType.FullName != fieldType.FullName)
// {
// // Call a convert method in the Convert static class, if available
// MethodInfo castMethod = typeof(Convert).GetMethod("To" + info.PropertyType.Name, new Type[] { fieldType });
// if (castMethod != null)
// {
// fieldValue = castMethod.Invoke(null, new object[] { fieldValue });
// }
// }

// // Set property value
// info.SetValue(data, fieldValue, null);
// }
// }

// // Add item to list
// list.Add(data);
// }

// return list;
//}
////catch
////{
//// throw;
////}
//finally
//{
// // Clean up reader and _connection
// if (reader != null)
// {
// reader.Close();
// reader.Dispose();
// }
try
{
//var mapping = new TableMapping(T);
connection = GenerateConnection();
command = connection.CreateCommand(sql, new object[0]);
list = command.ExecuteQuery<T>();

// // Dispose command
// command.Dispose();
return list;
}
catch
{
throw;
}
finally
{
connection.Close();
connection.Dispose();
}

// // Close and clean up _connection
// if (connection.State == ConnectionState.Open)
// {
// connection.Close();
// connection.Dispose();
// }
//}
return list;
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions MPfm/MPfm.Library/MPfm.Library.WindowsStore.csproj
Expand Up @@ -99,6 +99,7 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\1.05-1.06.sql" />
<EmbeddedResource Include="Scripts\1.03-1.04.sql" />
<EmbeddedResource Include="Scripts\1.02-1.03.sql" />
<EmbeddedResource Include="Scripts\1.01-1.02.sql" />
Expand Down
4 changes: 4 additions & 0 deletions MPfm/MPfm.Library/Services/WinRT/SyncClientService.cs
Expand Up @@ -15,6 +15,8 @@
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

#if WINDOWSSTORE || WINDOWS_PHONE

using System;
using System.Collections.Generic;
using System.Net.Http;
Expand Down Expand Up @@ -301,3 +303,5 @@ private string GetLibraryLocalPath(AudioFile audioFile)
}
}
}

#endif
2 changes: 2 additions & 0 deletions MPfm/MPfm.Library/Services/WinRT/SyncDiscoveryService.cs
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

#if WINDOWSSTORE || WINDOWS_PHONE
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -213,3 +214,4 @@ public void Cancel()
}
}
}
#endif
2 changes: 2 additions & 0 deletions MPfm/MPfm.Library/Services/WinRT/SyncListenerService.cs
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

#if WINDOWSSTORE || WINDOWS_PHONE
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -621,3 +622,4 @@ public SyncDevice GetInternalSyncDevice()
}
}
}
#endif
2 changes: 2 additions & 0 deletions MPfm/MPfm.Library/Services/WinRT/UpdateLibraryService.cs
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

#if WINDOWSSTORE || WINDOWS_PHONE
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -464,3 +465,4 @@ public List<string> SearchMediaFilesInFolders(string folderPath, bool recursive)
}
}
}
#endif
67 changes: 67 additions & 0 deletions MPfm/MPfm.MVP/Config/AppConfig.cs
@@ -0,0 +1,67 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using MPfm.MVP.Bootstrap;
using MPfm.MVP.Config.Providers;
using MPfm.MVP.Helpers;
using MPfm.Sound.AudioFiles;

namespace MPfm.MVP.Config
{
/// <summary>
/// Singleton containing all application settings.
/// </summary>
public class AppConfig
{
private readonly IAppConfigProvider _provider;
public RootAppConfig Root { get; private set; }

#region Singleton

private static AppConfig instance;
/// <summary>
/// AppConfig instance.
/// </summary>
public static AppConfig Instance
{
get
{
if(instance == null)
instance = new AppConfig();
return instance;
}
}

#endregion

public AppConfig()
{
_provider = Bootstrapper.GetContainer().Resolve<IAppConfigProvider>();
Root = new RootAppConfig();
}

public void Load()
{
Root = _provider.Load(ConfigurationHelper.ConfigurationFilePath);
}

public void Save()
{
_provider.Save(ConfigurationHelper.ConfigurationFilePath, Root);
}
}
}

0 comments on commit 49ee2cc

Please sign in to comment.