mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2024-11-15 03:00:23 +00:00
working on bug 666601
This commit is contained in:
parent
795f1ec3f8
commit
0aee8ad048
22 changed files with 129 additions and 203 deletions
|
@ -40,7 +40,7 @@ namespace MonoStockPortfolio.Core
|
||||||
|
|
||||||
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
|
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
|
||||||
{
|
{
|
||||||
Log.W("Upgrade", "Nothing to upgrade");
|
Log.Warn("Upgrade", "Nothing to upgrade");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,11 +31,7 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="FileHelpers">
|
|
||||||
<HintPath>..\libs\FileHelpers.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Mono.Android" />
|
<Reference Include="Mono.Android" />
|
||||||
<Reference Include="mscorlib" />
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -52,9 +48,8 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\IPortfolioService.cs" />
|
<Compile Include="Services\IPortfolioService.cs" />
|
||||||
<Compile Include="Services\PortfolioService.cs" />
|
<Compile Include="Services\PortfolioService.cs" />
|
||||||
|
<Compile Include="StockData\DummyStockDataProvider.cs" />
|
||||||
<Compile Include="StockData\IStockDataProvider.cs" />
|
<Compile Include="StockData\IStockDataProvider.cs" />
|
||||||
<Compile Include="StockData\YahooFinanceStockData.cs" />
|
|
||||||
<Compile Include="StockData\YahooStockDataProvider.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MonoStockPortfolio.Entities\MonoStockPortfolio.Entities.csproj">
|
<ProjectReference Include="..\MonoStockPortfolio.Entities\MonoStockPortfolio.Entities.csproj">
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
||||||
}
|
}
|
||||||
catch (SQLiteException)
|
catch (SQLiteException)
|
||||||
{
|
{
|
||||||
Log.E("DeletePortfolio", "SQLiteException => Id = " + portfolioId);
|
Log.Error("DeletePortfolio", "SQLiteException => Id = " + portfolioId);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -147,23 +147,23 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
||||||
private void UpdateExistingPortfolio(Portfolio portfolio)
|
private void UpdateExistingPortfolio(Portfolio portfolio)
|
||||||
{
|
{
|
||||||
var portfolioID = portfolio.ID ?? -1;
|
var portfolioID = portfolio.ID ?? -1;
|
||||||
Log.E("UpdateExistingPortfolio", "Portfolios updated: " + Db.Update(PORTFOLIO_TABLE_NAME, GetPortfolioContentValues(portfolio), "id = " + portfolioID, null));
|
Log.Error("UpdateExistingPortfolio", "Portfolios updated: " + Db.Update(PORTFOLIO_TABLE_NAME, GetPortfolioContentValues(portfolio), "id = " + portfolioID, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertNewPortfolio(Portfolio portfolio)
|
private void InsertNewPortfolio(Portfolio portfolio)
|
||||||
{
|
{
|
||||||
Log.E("InsertNewPortfolio", "Portfolios inserted: " + Db.Insert(PORTFOLIO_TABLE_NAME, null, GetPortfolioContentValues(portfolio)));
|
Log.Error("InsertNewPortfolio", "Portfolios inserted: " + Db.Insert(PORTFOLIO_TABLE_NAME, null, GetPortfolioContentValues(portfolio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateExistingPosition(Position position)
|
private void UpdateExistingPosition(Position position)
|
||||||
{
|
{
|
||||||
var positionID = position.ID ?? -1;
|
var positionID = position.ID ?? -1;
|
||||||
Log.E("UpdateExistingPosition", "Positions updated: " + Db.Update(POSITION_TABLE_NAME, GetPositionContentValues(position), "id = " + positionID, null));
|
Log.Error("UpdateExistingPosition", "Positions updated: " + Db.Update(POSITION_TABLE_NAME, GetPositionContentValues(position), "id = " + positionID, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertNewPosition(Position position)
|
private void InsertNewPosition(Position position)
|
||||||
{
|
{
|
||||||
Log.E("InsertNewPosition", "Positions inserted: " + Db.Insert(POSITION_TABLE_NAME, null, GetPositionContentValues(position)));
|
Log.Error("InsertNewPosition", "Positions inserted: " + Db.Insert(POSITION_TABLE_NAME, null, GetPositionContentValues(position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContentValues GetPortfolioContentValues(Portfolio portfolio)
|
private static ContentValues GetPortfolioContentValues(Portfolio portfolio)
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace MonoStockPortfolio.Core.Services
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.E("GetDetailedItems", ex.ToString());
|
Log.Error("GetDetailedItems", ex.ToString());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
MonoStockPortfolio.Core/StockData/DummyStockDataProvider.cs
Normal file
14
MonoStockPortfolio.Core/StockData/DummyStockDataProvider.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MonoStockPortfolio.Entities;
|
||||||
|
|
||||||
|
namespace MonoStockPortfolio.Core.StockData
|
||||||
|
{
|
||||||
|
public class DummyStockDataProvider : IStockDataProvider
|
||||||
|
{
|
||||||
|
public IEnumerable<StockQuote> GetStockQuotes(IEnumerable<string> enumerable)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
using FileHelpers;
|
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Core.StockData
|
|
||||||
{
|
|
||||||
[DelimitedRecord(",")]
|
|
||||||
public class YahooFinanceStockData
|
|
||||||
{
|
|
||||||
[FieldQuoted(QuoteMode.OptionalForBoth)]
|
|
||||||
public string Ticker;
|
|
||||||
|
|
||||||
public decimal LastTradePrice;
|
|
||||||
|
|
||||||
[FieldQuoted(QuoteMode.OptionalForBoth)]
|
|
||||||
public string Name;
|
|
||||||
|
|
||||||
public string Volume;
|
|
||||||
|
|
||||||
public decimal Change;
|
|
||||||
|
|
||||||
[FieldQuoted(QuoteMode.OptionalForBoth)]
|
|
||||||
public string LastTradeTime;
|
|
||||||
|
|
||||||
[FieldQuoted(QuoteMode.OptionalForBoth)]
|
|
||||||
public string RealTimeLastTradeWithTime;
|
|
||||||
|
|
||||||
[FieldQuoted(QuoteMode.OptionalForBoth)]
|
|
||||||
public string ChangeRealTime;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using Android.Util;
|
|
||||||
using FileHelpers;
|
|
||||||
using MonoStockPortfolio.Entities;
|
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Core.StockData
|
|
||||||
{
|
|
||||||
public class YahooStockDataProvider : IStockDataProvider
|
|
||||||
{
|
|
||||||
private const string LAST_TRADE_PRICE_ONLY = "l1";
|
|
||||||
private const string NAME = "n";
|
|
||||||
private const string VOLUME = "v";
|
|
||||||
private const string TICKER_SYMBOL = "s";
|
|
||||||
private const string CHANGE = "c1";
|
|
||||||
private const string LAST_TRADE_TIME = "t1";
|
|
||||||
private const string REAL_TIME_LAST_TRADE_WITH_TIME = "k1";
|
|
||||||
private const string REAL_TIME_CHANGE = "c6";
|
|
||||||
|
|
||||||
// http://www.gummy-stuff.org/Yahoo-data.htm
|
|
||||||
// http://finance.yahoo.com/d/quotes.csv?s= a BUNCH of
|
|
||||||
// STOCK SYMBOLS separated by "+" &f=a bunch of special tags
|
|
||||||
public IEnumerable<StockQuote> GetStockQuotes(IEnumerable<string> tickers)
|
|
||||||
{
|
|
||||||
string url = "http://finance.yahoo.com/d/quotes.csv?s=";
|
|
||||||
url += string.Join("+", tickers.ToArray());
|
|
||||||
url += "&f=";
|
|
||||||
url += TICKER_SYMBOL;
|
|
||||||
url += LAST_TRADE_PRICE_ONLY;
|
|
||||||
url += NAME;
|
|
||||||
url += VOLUME;
|
|
||||||
url += CHANGE;
|
|
||||||
url += LAST_TRADE_TIME;
|
|
||||||
url += REAL_TIME_LAST_TRADE_WITH_TIME;
|
|
||||||
url += REAL_TIME_CHANGE;
|
|
||||||
|
|
||||||
string resultCsv = ScrapeUrl(url);
|
|
||||||
|
|
||||||
var yahooQuoteData = ParseCsvIntoStockQuotes(resultCsv);
|
|
||||||
|
|
||||||
foreach (var quote in yahooQuoteData)
|
|
||||||
{
|
|
||||||
yield return MapYahooData(quote);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static StockQuote MapYahooData(YahooFinanceStockData data)
|
|
||||||
{
|
|
||||||
if(data == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var stock = new StockQuote();
|
|
||||||
stock.Name = data.Name;
|
|
||||||
stock.LastTradePrice = data.LastTradePrice;
|
|
||||||
stock.Ticker = data.Ticker;
|
|
||||||
stock.Volume = data.Volume;
|
|
||||||
stock.Change = data.Change;
|
|
||||||
stock.LastTradeTime = data.LastTradeTime;
|
|
||||||
stock.RealTimeLastTradePrice = decimal.Parse(data.RealTimeLastTradeWithTime
|
|
||||||
.Replace("<b>", "")
|
|
||||||
.Replace("</b>", "")
|
|
||||||
.Replace("N/A -", "")
|
|
||||||
.Trim()
|
|
||||||
);
|
|
||||||
stock.ChangeRealTime = data.ChangeRealTime;
|
|
||||||
return stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IList<YahooFinanceStockData> ParseCsvIntoStockQuotes(string csv)
|
|
||||||
{
|
|
||||||
var engine = new FileHelperEngine(typeof(YahooFinanceStockData));
|
|
||||||
var stockQuotes = engine.ReadString(csv) as YahooFinanceStockData[];
|
|
||||||
if(stockQuotes == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Could not parse CSV input");
|
|
||||||
}
|
|
||||||
return stockQuotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ScrapeUrl(string url)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string resultCsv;
|
|
||||||
var req = WebRequest.Create(url);
|
|
||||||
var resp = req.GetResponse();
|
|
||||||
using (var sr = new StreamReader(resp.GetResponseStream()))
|
|
||||||
{
|
|
||||||
resultCsv = sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
}
|
|
||||||
return resultCsv;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.E("ScrapeUrlException", ex.ToString());
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,7 +31,6 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="mscorlib" />
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|
|
@ -8,11 +8,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{643BA3D4-E
|
||||||
libs\FileHelpers.dll = libs\FileHelpers.dll
|
libs\FileHelpers.dll = libs\FileHelpers.dll
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{4EE7F6AD-B8A9-4402-800E-E4C8AE0FF8FB}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
assets\UInotes.txt = assets\UInotes.txt
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoStockPortfolio.Core", "MonoStockPortfolio.Core\MonoStockPortfolio.Core.csproj", "{251E7BB4-CFE2-4DE4-9E2A-AAE1AF41C8CB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoStockPortfolio.Core", "MonoStockPortfolio.Core\MonoStockPortfolio.Core.csproj", "{251E7BB4-CFE2-4DE4-9E2A-AAE1AF41C8CB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoStockPortfolio.Entities", "MonoStockPortfolio.Entities\MonoStockPortfolio.Entities.csproj", "{05A57650-3B41-46FF-9EAD-9112B5EFBEED}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoStockPortfolio.Entities", "MonoStockPortfolio.Entities\MonoStockPortfolio.Entities.csproj", "{05A57650-3B41-46FF-9EAD-9112B5EFBEED}"
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
AddPreferencesFromResource(Resource.layout.config);
|
AddPreferencesFromResource(Resource.Layout.config);
|
||||||
|
|
||||||
_stockItemsConfig = StockItemPreference.BuildList(_repo.GetStockItems()).ToArray();
|
_stockItemsConfig = StockItemPreference.BuildList(_repo.GetStockItems()).ToArray();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
SetContentView(Resource.layout.addportfolio);
|
SetContentView(Resource.Layout.addportfolio);
|
||||||
|
|
||||||
WireUpEvents();
|
WireUpEvents();
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
public static string Extra_PortfolioID { get { return "monoStockPortfolio.EditPortfolioActivity.PortfolioID"; } }
|
public static string Extra_PortfolioID { get { return "monoStockPortfolio.EditPortfolioActivity.PortfolioID"; } }
|
||||||
public long ThisPortfolioId { get { return Intent.GetLongExtra(Extra_PortfolioID, -1); } }
|
public long ThisPortfolioId { get { return Intent.GetLongExtra(Extra_PortfolioID, -1); } }
|
||||||
|
|
||||||
protected Button SaveButton { get { return FindViewById<Button>(Resource.id.btnSave); } }
|
protected Button SaveButton { get { return FindViewById<Button>(Resource.Id.btnSave); } }
|
||||||
protected EditText PortfolioName { get { return FindViewById<EditText>(Resource.id.portfolioName); } }
|
protected EditText PortfolioName { get { return FindViewById<EditText>(Resource.Id.portfolioName); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
SetContentView(Resource.layout.addposition);
|
SetContentView(Resource.Layout.addposition);
|
||||||
|
|
||||||
var positionId = ThisPositionId;
|
var positionId = ThisPositionId;
|
||||||
if (positionId != -1)
|
if (positionId != -1)
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace MonoStockPortfolio.Activites
|
||||||
public static string Extra_PositionID { get { return "monoStockPortfolio.EditPositionActivity.PositionID"; } }
|
public static string Extra_PositionID { get { return "monoStockPortfolio.EditPositionActivity.PositionID"; } }
|
||||||
public long ThisPositionId { get { return Intent.GetLongExtra(Extra_PositionID, -1); } }
|
public long ThisPositionId { get { return Intent.GetLongExtra(Extra_PositionID, -1); } }
|
||||||
|
|
||||||
protected EditText TickerTextBox { get { return FindViewById<EditText>(Resource.id.addPositionTicker); } }
|
protected EditText TickerTextBox { get { return FindViewById<EditText>(Resource.Id.addPositionTicker); } }
|
||||||
protected EditText PriceTextBox { get { return FindViewById<EditText>(Resource.id.addPositionPrice); } }
|
protected EditText PriceTextBox { get { return FindViewById<EditText>(Resource.Id.addPositionPrice); } }
|
||||||
protected EditText SharesTextBox { get { return FindViewById<EditText>(Resource.id.addPositionShares); } }
|
protected EditText SharesTextBox { get { return FindViewById<EditText>(Resource.Id.addPositionShares); } }
|
||||||
protected Button SaveButton { get { return FindViewById<Button>(Resource.id.addPositionSaveButton); } }
|
protected Button SaveButton { get { return FindViewById<Button>(Resource.Id.addPositionSaveButton); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
SetContentView(Resource.layout.main);
|
SetContentView(Resource.Layout.main);
|
||||||
|
|
||||||
RefreshList();
|
RefreshList();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
_portfolios = _repo.GetAllPortfolios();
|
_portfolios = _repo.GetAllPortfolios();
|
||||||
|
|
||||||
var listAdapter = new ArrayAdapter<string>(this, Android.R.Layout.SimpleListItem1, _portfolios.Select(p => p.Name).ToList());
|
var listAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, _portfolios.Select(p => p.Name).ToList());
|
||||||
PortfolioListView.Adapter = listAdapter;
|
PortfolioListView.Adapter = listAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ namespace MonoStockPortfolio.Activites
|
||||||
public override bool OnCreateOptionsMenu(IMenu menu)
|
public override bool OnCreateOptionsMenu(IMenu menu)
|
||||||
{
|
{
|
||||||
var configItem = menu.Add(0, 1, 1, "Config");
|
var configItem = menu.Add(0, 1, 1, "Config");
|
||||||
configItem.SetIcon(Android.R.Drawable.IcMenuPreferences);
|
configItem.SetIcon(Android.Resource.Drawable.IcMenuPreferences);
|
||||||
var exitItem = menu.Add(0, 1, 1, "Exit");
|
var exitItem = menu.Add(0, 1, 1, "Exit");
|
||||||
exitItem.SetIcon(Android.R.Drawable.IcMenuCloseClearCancel);
|
exitItem.SetIcon(Android.Resource.Drawable.IcMenuCloseClearCancel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
public static string ClassName { get { return "monostockportfolio.activites.MainActivity"; } }
|
public static string ClassName { get { return "monostockportfolio.activites.MainActivity"; } }
|
||||||
|
|
||||||
protected Button AddPortfolioButton { get { return FindViewById<Button>(Resource.id.btnAddPortfolio); } }
|
protected Button AddPortfolioButton { get { return FindViewById<Button>(Resource.Id.btnAddPortfolio); } }
|
||||||
protected ListView PortfolioListView { get { return FindViewById<ListView>(Resource.id.portfolioList); } }
|
protected ListView PortfolioListView { get { return FindViewById<ListView>(Resource.Id.portfolioList); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,7 +27,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
{
|
{
|
||||||
base.OnCreate(bundle);
|
base.OnCreate(bundle);
|
||||||
|
|
||||||
SetContentView(Resource.layout.portfolio);
|
SetContentView(Resource.Layout.portfolio);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
public override bool OnCreateOptionsMenu(IMenu menu)
|
public override bool OnCreateOptionsMenu(IMenu menu)
|
||||||
{
|
{
|
||||||
var item = menu.Add(0,1,1,"Refresh");
|
var item = menu.Add(0,1,1,"Refresh");
|
||||||
item.SetIcon(Resource.drawable.ic_menu_refresh);
|
item.SetIcon(Resource.Drawable.ic_menu_refresh);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace MonoStockPortfolio.Activites
|
||||||
|
|
||||||
private void ShowMessage(string message)
|
private void ShowMessage(string message)
|
||||||
{
|
{
|
||||||
var listAdapter = new ArrayAdapter<string>(this, Android.R.Layout.SimpleListItem1, new[] {message});
|
var listAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, new[] { message });
|
||||||
QuoteListview.Adapter = listAdapter;
|
QuoteListview.Adapter = listAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,10 +134,10 @@ namespace MonoStockPortfolio.Activites
|
||||||
var textItem = new TextView(this);
|
var textItem = new TextView(this);
|
||||||
textItem.Text = stockDataItem.GetStringValue();
|
textItem.Text = stockDataItem.GetStringValue();
|
||||||
textItem.SetWidth(cellwidth);
|
textItem.SetWidth(cellwidth);
|
||||||
textItem.SetTextColor(Resources.GetColor(Android.R.Color.Black));
|
textItem.SetTextColor(Resources.GetColor(Android.Resource.Color.Black));
|
||||||
QuoteListviewHeader.AddView(textItem);
|
QuoteListviewHeader.AddView(textItem);
|
||||||
}
|
}
|
||||||
QuoteListviewHeader.SetBackgroundResource(Android.R.Color.BackgroundLight);
|
QuoteListviewHeader.SetBackgroundResource(Android.Resource.Color.BackgroundLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PositionArrayAdapter : GenericArrayAdapter<PositionResultsViewModel>
|
public class PositionArrayAdapter : GenericArrayAdapter<PositionResultsViewModel>
|
||||||
|
|
|
@ -9,8 +9,8 @@ namespace MonoStockPortfolio.Activites
|
||||||
public static string Extra_PortfolioID { get { return "monoStockPortfolio.PortfolioActivity.PortfolioID"; } }
|
public static string Extra_PortfolioID { get { return "monoStockPortfolio.PortfolioActivity.PortfolioID"; } }
|
||||||
public long ThisPortofolioId { get { return Intent.GetLongExtra(Extra_PortfolioID, -1); } }
|
public long ThisPortofolioId { get { return Intent.GetLongExtra(Extra_PortfolioID, -1); } }
|
||||||
|
|
||||||
protected ListView QuoteListview { get { return FindViewById<ListView>(Resource.id.quoteListview); } }
|
protected ListView QuoteListview { get { return FindViewById<ListView>(Resource.Id.quoteListview); } }
|
||||||
protected Button AddPositionButton { get { return FindViewById<Button>(Resource.id.btnAddPosition); } }
|
protected Button AddPositionButton { get { return FindViewById<Button>(Resource.Id.btnAddPosition); } }
|
||||||
protected LinearLayout QuoteListviewHeader { get { return FindViewById<LinearLayout>(Resource.id.quoteHeaderLayout); } }
|
protected LinearLayout QuoteListviewHeader { get { return FindViewById<LinearLayout>(Resource.Id.quoteHeaderLayout); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,18 +5,18 @@ namespace MonoStockPortfolio.Framework
|
||||||
{
|
{
|
||||||
public class IoCAttribute : LocationInterceptionAspect
|
public class IoCAttribute : LocationInterceptionAspect
|
||||||
{
|
{
|
||||||
public override void OnGetValue(LocationInterceptionArgs args)
|
public sealed override void OnGetValue(LocationInterceptionArgs args)
|
||||||
{
|
{
|
||||||
if (ServiceLocator.Context == null)
|
if (ServiceLocator.Context == null)
|
||||||
{
|
{
|
||||||
var activityContext= (Context)args.Instance;
|
var activityContext = (Context)args.Instance;
|
||||||
ServiceLocator.Context = activityContext.ApplicationContext.ApplicationContext;
|
ServiceLocator.Context = activityContext.ApplicationContext.ApplicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
var locationType = args.Location.LocationType;
|
var locationType = args.Location.LocationType;
|
||||||
var instantiation = ServiceLocator.Get(locationType);
|
var instantiation = ServiceLocator.Get(locationType);
|
||||||
|
|
||||||
if(instantiation != null)
|
if (instantiation != null)
|
||||||
{
|
{
|
||||||
args.SetNewValue(instantiation);
|
args.SetNewValue(instantiation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using MonoStockPortfolio.Core.Config;
|
using MonoStockPortfolio.Core.Config;
|
||||||
using MonoStockPortfolio.Core.PortfolioRepositories;
|
using MonoStockPortfolio.Core.PortfolioRepositories;
|
||||||
using MonoStockPortfolio.Core.Services;
|
using MonoStockPortfolio.Core.Services;
|
||||||
using MonoStockPortfolio.Core.StockData;
|
using MonoStockPortfolio.Core.StockData;
|
||||||
|
using MonoStockPortfolio.Entities;
|
||||||
using TinyIoC;
|
using TinyIoC;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Framework
|
namespace MonoStockPortfolio.Framework
|
||||||
|
@ -27,12 +29,60 @@ namespace MonoStockPortfolio.Framework
|
||||||
var container = TinyIoCContainer.Current;
|
var container = TinyIoCContainer.Current;
|
||||||
|
|
||||||
container.Register<Context>(Context);
|
container.Register<Context>(Context);
|
||||||
container.Register<IStockDataProvider, YahooStockDataProvider>().AsMultiInstance();
|
container.Register<IStockDataProvider, DummyStockDataProvider>().AsMultiInstance(); // works
|
||||||
container.Register<IPortfolioService, PortfolioService>().AsMultiInstance();
|
container.Register<IPortfolioService, PortfolioService>().AsMultiInstance(); // works
|
||||||
container.Register<IPortfolioRepository, AndroidSqlitePortfolioRepository>().AsMultiInstance();
|
container.Register<IPortfolioRepository, Whatever>().AsMultiInstance(); // error
|
||||||
container.Register<IConfigRepository, AndroidSqliteConfigRepository>().AsMultiInstance();
|
//container.Register<IConfigRepository, AndroidSqliteConfigRepository>().AsMultiInstance(); // error
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Whatever : IPortfolioRepository
|
||||||
|
{
|
||||||
|
public IList<Portfolio> GetAllPortfolios()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SavePortfolio(Portfolio portfolio)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeletePortfolioById(int portfolioId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Portfolio GetPortfolioById(long portfolioId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Portfolio GetPortfolioByName(string portfolioName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<Position> GetAllPositions(long portfolioId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SavePosition(Position position)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeletePositionById(long positionId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position GetPositionById(long positionId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="PostSharp.SL, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL">
|
<Reference Include="PostSharp.SL, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\libs\PostSharp.SL.dll</HintPath>
|
<HintPath>..\..\..\Program Files (x86)\PostSharp 2.0\Reference Assemblies\Silverlight 3.0\PostSharp.SL.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -59,7 +59,6 @@
|
||||||
<Compile Include="Framework\ActivityExtensions.cs" />
|
<Compile Include="Framework\ActivityExtensions.cs" />
|
||||||
<Compile Include="Framework\ContextExtensions.cs" />
|
<Compile Include="Framework\ContextExtensions.cs" />
|
||||||
<Compile Include="Framework\GenericArrayAdapter.cs" />
|
<Compile Include="Framework\GenericArrayAdapter.cs" />
|
||||||
<Compile Include="Framework\IoCAttribute.cs" />
|
|
||||||
<Compile Include="Activites\MainActivity.designer.cs">
|
<Compile Include="Activites\MainActivity.designer.cs">
|
||||||
<DependentUpon>MainActivity.cs</DependentUpon>
|
<DependentUpon>MainActivity.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -69,6 +68,7 @@
|
||||||
<Compile Include="Activites\PortfolioActivity.designer.cs">
|
<Compile Include="Activites\PortfolioActivity.designer.cs">
|
||||||
<DependentUpon>PortfolioActivity.cs</DependentUpon>
|
<DependentUpon>PortfolioActivity.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Framework\IoCAttribute.cs" />
|
||||||
<Compile Include="Framework\ServiceLocator.cs" />
|
<Compile Include="Framework\ServiceLocator.cs" />
|
||||||
<Compile Include="Framework\TinyIoC.cs" />
|
<Compile Include="Framework\TinyIoC.cs" />
|
||||||
<Compile Include="Resources\Resource.Designer.cs" />
|
<Compile Include="Resources\Resource.Designer.cs" />
|
||||||
|
@ -77,9 +77,7 @@
|
||||||
<Compile Include="Framework\FormValidator.cs" />
|
<Compile Include="Framework\FormValidator.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="PostSharp.Custom.targets">
|
<None Include="PostSharp.Custom.targets" />
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="Resources\AboutResources.txt" />
|
<None Include="Resources\AboutResources.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -119,17 +117,26 @@
|
||||||
</AndroidResource>
|
</AndroidResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
|
<AndroidResource Include="Resources\layout\config.xml" />
|
||||||
<AndroidResource Include="Resources\drawable-ldpi\icon.png" />
|
|
||||||
<AndroidResource Include="Resources\drawable-mdpi\icon.png" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\drawable-hdpi\ic_menu_refresh.png" />
|
<AndroidResource Include="Resources\drawable-hdpi\ic_menu_refresh.png" />
|
||||||
<AndroidResource Include="Resources\drawable-ldpi\ic_menu_refresh.png" />
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\drawable-mdpi\ic_menu_refresh.png" />
|
<AndroidResource Include="Resources\drawable-mdpi\ic_menu_refresh.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\layout\config.xml" />
|
<AndroidResource Include="Resources\drawable-mdpi\icon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-ldpi\ic_menu_refresh.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-ldpi\icon.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
20
MonoStockPortfolio/Resources/Resource.Designer.cs
generated
20
MonoStockPortfolio/Resources/Resource.Designer.cs
generated
|
@ -15,15 +15,15 @@ namespace MonoStockPortfolio
|
||||||
public partial class Resource
|
public partial class Resource
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class attr
|
public partial class Attribute
|
||||||
{
|
{
|
||||||
|
|
||||||
private attr()
|
private Attribute()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class drawable
|
public partial class Drawable
|
||||||
{
|
{
|
||||||
|
|
||||||
// aapt resource value: 0x7f020000
|
// aapt resource value: 0x7f020000
|
||||||
|
@ -32,12 +32,12 @@ namespace MonoStockPortfolio
|
||||||
// aapt resource value: 0x7f020001
|
// aapt resource value: 0x7f020001
|
||||||
public const int icon = 2130837505;
|
public const int icon = 2130837505;
|
||||||
|
|
||||||
private drawable()
|
private Drawable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class id
|
public partial class Id
|
||||||
{
|
{
|
||||||
|
|
||||||
// aapt resource value: 0x7f050004
|
// aapt resource value: 0x7f050004
|
||||||
|
@ -73,12 +73,12 @@ namespace MonoStockPortfolio
|
||||||
// aapt resource value: 0x7f05000a
|
// aapt resource value: 0x7f05000a
|
||||||
public const int quoteListview = 2131034122;
|
public const int quoteListview = 2131034122;
|
||||||
|
|
||||||
private id()
|
private Id()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class layout
|
public partial class Layout
|
||||||
{
|
{
|
||||||
|
|
||||||
// aapt resource value: 0x7f030000
|
// aapt resource value: 0x7f030000
|
||||||
|
@ -96,12 +96,12 @@ namespace MonoStockPortfolio
|
||||||
// aapt resource value: 0x7f030004
|
// aapt resource value: 0x7f030004
|
||||||
public const int portfolio = 2130903044;
|
public const int portfolio = 2130903044;
|
||||||
|
|
||||||
private layout()
|
private Layout()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class @string
|
public partial class String
|
||||||
{
|
{
|
||||||
|
|
||||||
// aapt resource value: 0x7f040001
|
// aapt resource value: 0x7f040001
|
||||||
|
@ -110,7 +110,7 @@ namespace MonoStockPortfolio
|
||||||
// aapt resource value: 0x7f040000
|
// aapt resource value: 0x7f040000
|
||||||
public const int hello = 2130968576;
|
public const int hello = 2130968576;
|
||||||
|
|
||||||
private @string()
|
private String()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue