diff --git a/MonoStockPortfolio.Core/Config/AndroidSqliteConfigRepository.cs b/MonoStockPortfolio.Core/Config/AndroidSqliteConfigRepository.cs index cb65e3d..aa80e5c 100644 --- a/MonoStockPortfolio.Core/Config/AndroidSqliteConfigRepository.cs +++ b/MonoStockPortfolio.Core/Config/AndroidSqliteConfigRepository.cs @@ -1,17 +1,18 @@ -using System; +using System.Collections.Generic; +using MonoStockPortfolio.Entities; namespace MonoStockPortfolio.Core.Config { public class AndroidSqliteConfigRepository : IConfigRepository { - public ConfigManager.Config LoadOrCreateConfig() + public IEnumerable GetStockItems() { - throw new NotImplementedException(); - } - - public void SaveConfig(ConfigManager.Config config) - { - throw new NotImplementedException(); + var items = new List(); + items.Add(StockDataItem.Ticker); + items.Add(StockDataItem.LastTradePrice); + items.Add(StockDataItem.GainLossRealTime); + items.Add(StockDataItem.Time); + return items; } } } \ No newline at end of file diff --git a/MonoStockPortfolio.Core/Config/ConfigManager.cs b/MonoStockPortfolio.Core/Config/ConfigManager.cs deleted file mode 100644 index fed0e1c..0000000 --- a/MonoStockPortfolio.Core/Config/ConfigManager.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using MonoStockPortfolio.Core.Services; -using MonoStockPortfolio.Core.Config; -using MonoStockPortfolio.Entities; - -namespace MonoStockPortfolio.Core.Config -{ - public class ConfigManager - { - public class Config - { - public Config() - { - StockDetailItems = new List(); - } - public IList StockDetailItems { get; set; } - public bool AgreedToTermsOfService { get; set; } - } - - private IConfigRepository _repo; - private Config _config; - - public ConfigManager() : this(new AndroidSqliteConfigRepository()) {} - - public ConfigManager(IConfigRepository repository) - { - _repo = repository; - _config = _repo.LoadOrCreateConfig(); - } - - public bool AgreedToTos - { - get { - return _config.AgreedToTermsOfService; - } - set - { - _config.AgreedToTermsOfService = value; - _repo.SaveConfig(_config); - } - } - - public void UpdateStockDetailItems(IList newStockDetailItems) - { - _config.StockDetailItems = newStockDetailItems; - _repo.SaveConfig(_config); - } - - public IEnumerable GetStockDetailItems() - { - return _config.StockDetailItems; - } - } -} diff --git a/MonoStockPortfolio.Core/Config/IConfigRepository.cs b/MonoStockPortfolio.Core/Config/IConfigRepository.cs index 7245bf9..d8e2cbf 100644 --- a/MonoStockPortfolio.Core/Config/IConfigRepository.cs +++ b/MonoStockPortfolio.Core/Config/IConfigRepository.cs @@ -1,8 +1,10 @@ +using System.Collections.Generic; +using MonoStockPortfolio.Entities; + namespace MonoStockPortfolio.Core.Config { public interface IConfigRepository { - ConfigManager.Config LoadOrCreateConfig(); - void SaveConfig(ConfigManager.Config config); + IEnumerable GetStockItems(); } } \ No newline at end of file diff --git a/MonoStockPortfolio.Core/MonoStockPortfolio.Core.csproj b/MonoStockPortfolio.Core/MonoStockPortfolio.Core.csproj index 1626d04..eaad376 100644 --- a/MonoStockPortfolio.Core/MonoStockPortfolio.Core.csproj +++ b/MonoStockPortfolio.Core/MonoStockPortfolio.Core.csproj @@ -43,7 +43,6 @@ - diff --git a/MonoStockPortfolio.Core/PortfolioRepositories/AndroidSqlitePortfolioRepository.cs b/MonoStockPortfolio.Core/PortfolioRepositories/AndroidSqlitePortfolioRepository.cs index a3ecf78..8881496 100644 --- a/MonoStockPortfolio.Core/PortfolioRepositories/AndroidSqlitePortfolioRepository.cs +++ b/MonoStockPortfolio.Core/PortfolioRepositories/AndroidSqlitePortfolioRepository.cs @@ -229,6 +229,4 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories } } } - - } \ No newline at end of file diff --git a/MonoStockPortfolio/Activites/PortfolioActivity.cs b/MonoStockPortfolio/Activites/PortfolioActivity.cs index dbf6eb3..ffe3bd9 100644 --- a/MonoStockPortfolio/Activites/PortfolioActivity.cs +++ b/MonoStockPortfolio/Activites/PortfolioActivity.cs @@ -8,6 +8,7 @@ using Android.OS; using Android.Views; using Android.Widget; using MonoStockPortfolio.Core; +using MonoStockPortfolio.Core.Config; using MonoStockPortfolio.Core.PortfolioRepositories; using MonoStockPortfolio.Core.Services; using MonoStockPortfolio.Entities; @@ -20,6 +21,7 @@ namespace MonoStockPortfolio.Activites { [IoC] private IPortfolioService _svc; [IoC] private IPortfolioRepository _repo; + [IoC] private IConfigRepository _config; protected override void OnCreate(Bundle bundle) { @@ -123,10 +125,10 @@ namespace MonoStockPortfolio.Activites QuoteListview.Adapter = listAdapter; } - private void UpdateHeader(ICollection items) + private void UpdateHeader(IEnumerable items) { QuoteListviewHeader.RemoveAllViews(); - var cellwidth = this.GetScreenWidth()/items.Count; + var cellwidth = this.GetScreenWidth()/items.Count(); foreach (var stockDataItem in items) { var textItem = new TextView(this); @@ -157,7 +159,8 @@ namespace MonoStockPortfolio.Activites var row = new LinearLayout(Context); row.Orientation = Orientation.Horizontal; - foreach (var stockDataItem in GetStockItemsFromConfig()) + var portfolioActivity = (PortfolioActivity) Context; + foreach (var stockDataItem in portfolioActivity.GetStockItemsFromConfig()) { var cell = new TextView(Context); cell.Text = item.Items[stockDataItem]; @@ -199,15 +202,9 @@ namespace MonoStockPortfolio.Activites - public static List GetStockItemsFromConfig() + public IEnumerable GetStockItemsFromConfig() { - // TODO: load this from a config - var items = new List(); - items.Add(StockDataItem.Ticker); - items.Add(StockDataItem.LastTradePrice); - items.Add(StockDataItem.GainLossRealTime); - items.Add(StockDataItem.Time); - return items; + return _config.GetStockItems(); } } } \ No newline at end of file diff --git a/MonoStockPortfolio/Framework/ServiceLocator.cs b/MonoStockPortfolio/Framework/ServiceLocator.cs index 8022438..dd67df3 100644 --- a/MonoStockPortfolio/Framework/ServiceLocator.cs +++ b/MonoStockPortfolio/Framework/ServiceLocator.cs @@ -1,5 +1,6 @@ using System; using Android.Content; +using MonoStockPortfolio.Core.Config; using MonoStockPortfolio.Core.PortfolioRepositories; using MonoStockPortfolio.Core.Services; using MonoStockPortfolio.Core.StockData; @@ -29,6 +30,7 @@ namespace MonoStockPortfolio.Framework container.Register().AsMultiInstance(); container.Register().AsMultiInstance(); container.Register().AsMultiInstance(); + container.Register().AsMultiInstance(); return container; }