mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2024-12-26 03:00:17 +00:00
Merge branch 'refresh_stocks_thread'
This commit is contained in:
commit
8c749c667f
7 changed files with 29 additions and 33 deletions
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using Android.Content;
|
||||
using Android.Database.Sqlite;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
using MonoStockPortfolio.Entities;
|
||||
|
||||
namespace MonoStockPortfolio.Core.PortfolioRepositories
|
||||
|
@ -12,7 +11,6 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
|||
{
|
||||
private OpenHelper _dbHelper;
|
||||
private SQLiteDatabase _db;
|
||||
private Context _context;
|
||||
private const string PORTFOLIO_TABLE_NAME = "Portfolios";
|
||||
private const string DATABASE_NAME = "stockportfolio.db";
|
||||
private const int DATABASE_VERSION = 1;
|
||||
|
@ -20,7 +18,6 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
|||
|
||||
public AndroidSqlitePortfolioRepository(Context context)
|
||||
{
|
||||
_context = context;
|
||||
_dbHelper = new OpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
_db = _dbHelper.WritableDatabase;
|
||||
}
|
||||
|
|
|
@ -11,18 +11,15 @@ namespace MonoStockPortfolio
|
|||
[Activity(Label = "Add Portfolio", MainLauncher = false)]
|
||||
public class AddPortfolioActivity : Activity
|
||||
{
|
||||
public AddPortfolioActivity(IntPtr handle) : base(handle)
|
||||
{
|
||||
_repo = new AndroidSqlitePortfolioRepository(this);
|
||||
}
|
||||
|
||||
public static string ClassName { get { return "monoStockPortfolio.AddPortfolioActivity"; } }
|
||||
public static string ClassName { get { return "monostockportfolio.AddPortfolioActivity"; } }
|
||||
private IPortfolioRepository _repo;
|
||||
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
base.OnCreate(bundle);
|
||||
|
||||
_repo = new AndroidSqlitePortfolioRepository(this);
|
||||
|
||||
SetContentView(Resource.layout.addportfolio);
|
||||
|
||||
WireUpEvents();
|
||||
|
|
|
@ -12,12 +12,7 @@ namespace MonoStockPortfolio
|
|||
[Activity(Label = "Add Position", MainLauncher = false)]
|
||||
public class AddPositionActivity : Activity
|
||||
{
|
||||
public AddPositionActivity(IntPtr handle) : base(handle)
|
||||
{
|
||||
_repo = new AndroidSqlitePortfolioRepository(this);
|
||||
}
|
||||
|
||||
public static string ClassName { get { return "monoStockPortfolio.AddPositionActivity"; } }
|
||||
public static string ClassName { get { return "monostockportfolio.AddPositionActivity"; } }
|
||||
public static string Extra_PortfolioID { get { return "monoStockPortfolio.AddPositionActivity.PortfolioID"; } }
|
||||
|
||||
private IPortfolioRepository _repo;
|
||||
|
@ -33,6 +28,8 @@ namespace MonoStockPortfolio
|
|||
|
||||
SetContentView(Resource.layout.addposition);
|
||||
|
||||
_repo = new AndroidSqlitePortfolioRepository(this);
|
||||
|
||||
SaveButton.Click += saveButton_Click;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,7 @@ namespace MonoStockPortfolio
|
|||
[Activity(Label = "Stock Portfolio", MainLauncher = true, Icon = "@drawable/icon")]
|
||||
public class MainActivity : Activity
|
||||
{
|
||||
public static string ClassName { get { return "monoStockPortfolio.MainActivity"; } }
|
||||
public MainActivity(IntPtr handle) : base(handle)
|
||||
{
|
||||
_svc = new PortfolioService(this);
|
||||
}
|
||||
public static string ClassName { get { return "monostockportfolio.MainActivity"; } }
|
||||
|
||||
private IPortfolioService _svc;
|
||||
private IList<Portfolio> _portfolios;
|
||||
|
@ -26,6 +22,8 @@ namespace MonoStockPortfolio
|
|||
{
|
||||
base.OnCreate(bundle);
|
||||
|
||||
_svc = new PortfolioService(this);
|
||||
|
||||
SetContentView(Resource.layout.main);
|
||||
|
||||
RefreshList();
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||
<AndroidSupportedAbis>armeabi</AndroidSupportedAbis>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -5,6 +5,7 @@ using Android.App;
|
|||
using Android.Content;
|
||||
using Android.Graphics;
|
||||
using Android.OS;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
using MonoStockPortfolio.Core;
|
||||
using MonoStockPortfolio.Core.Services;
|
||||
|
@ -14,12 +15,7 @@ namespace MonoStockPortfolio
|
|||
[Activity(Label = "Portfolio")]
|
||||
public class PortfolioActivity : Activity
|
||||
{
|
||||
public PortfolioActivity(IntPtr handle) : base(handle)
|
||||
{
|
||||
_svc = new PortfolioService(this);
|
||||
}
|
||||
|
||||
public static string ClassName { get { return "monoStockPortfolio.PortfolioActivity"; } }
|
||||
public static string ClassName { get { return "monostockportfolio.PortfolioActivity"; } }
|
||||
public static string Extra_PortfolioID { get { return "monoStockPortfolio.PortfolioActivity.PortfolioID"; } }
|
||||
private IPortfolioService _svc;
|
||||
private IEnumerable<char>[] longClickOptions;
|
||||
|
@ -30,20 +26,28 @@ namespace MonoStockPortfolio
|
|||
{
|
||||
base.OnCreate(bundle);
|
||||
|
||||
try
|
||||
{
|
||||
SetContentView(Resource.layout.portfolio);
|
||||
|
||||
_svc = new PortfolioService(this);
|
||||
|
||||
Refresh();
|
||||
|
||||
WireUpEvents();
|
||||
|
||||
SetTitle();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.E("EXCEPTION", ex.ToString());
|
||||
Toast.MakeText(this, ex.ToString(), ToastLength.Long);
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
// TODO: put this in another thread or something, perhaps?
|
||||
var tickers = _svc.GetDetailedItems(ThisPortofolioId, GetStockItemsFromConfig());
|
||||
|
||||
if (tickers.Any())
|
||||
{
|
||||
var tableLayout = FindViewById<TableLayout>(Resource.id.quoteTable);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="MonoStockPortfolio.MonoStockPortfolio" android:versionCode="1" android:versionName="1.0">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.monostockportfolio" android:versionCode="1" android:versionName="1.0">
|
||||
<application android:label="MonoStockPortfolio">
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
|
|
Loading…
Reference in a new issue