mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2025-01-13 19:31:30 +00:00
adjusted onworkerthread--I may not even need all this multithreaded malarkey, but I'll look into that later
This commit is contained in:
parent
132655170b
commit
3164d4a3c7
5 changed files with 27 additions and 22 deletions
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.Content;
|
||||
using MonoStockPortfolio.Entities;
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
<Compile Include="CsvParserTests.cs" />
|
||||
<Compile Include="GoogleStockQuoteTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="YahooStockDataProviderTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MonoStockPortfolio.Core\MonoStockPortfolio.Core.csproj">
|
||||
|
|
17
MonoStockPortfolio.Tests/YahooStockDataProviderTests.cs
Normal file
17
MonoStockPortfolio.Tests/YahooStockDataProviderTests.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Linq;
|
||||
using MonoStockPortfolio.Core.StockData;
|
||||
using Xunit;
|
||||
|
||||
namespace MonoStockPortfolio.Tests
|
||||
{
|
||||
public class YahooStockDataProviderTests
|
||||
{
|
||||
[Fact]
|
||||
public void Can_get_volume()
|
||||
{
|
||||
var svc = new YahooStockDataProvider();
|
||||
var quote = svc.GetStockQuotes(new[] {"XIN"}).Single();
|
||||
Assert.True(!string.IsNullOrEmpty(quote.Volume));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using Android.App;
|
||||
using Android.Util;
|
||||
using PostSharp.Aspects;
|
||||
|
||||
namespace MonoStockPortfolio.Framework
|
||||
|
@ -19,7 +18,6 @@ namespace MonoStockPortfolio.Framework
|
|||
args.ProceedGetValue(); // this actually fetches the field and populates the args.Value
|
||||
if (args.Value == null)
|
||||
{
|
||||
Log.Info("OnGetValue", "FindViewById called for " + args.LocationFullName);
|
||||
var activity = args.Instance as Activity;
|
||||
if (activity == null) throw new ArgumentException("LazyViewAttribute can only be used within Activities");
|
||||
args.SetNewValue(activity.FindViewById(_viewId));
|
||||
|
|
|
@ -7,36 +7,26 @@ namespace MonoStockPortfolio.Framework
|
|||
{
|
||||
public class OnWorkerThreadAttribute : MethodInterceptionAspect
|
||||
{
|
||||
private ProgressDialog _progressDialog;
|
||||
|
||||
public override void OnInvoke(MethodInterceptionArgs args)
|
||||
{
|
||||
var activity = args.Instance as Activity;
|
||||
if(activity == null) throw new Exception("OnWorkerThread can only be used on methods in Activity classes");
|
||||
|
||||
ShowProgressDialog(activity);
|
||||
var pd = ShowProgressDialog(activity);
|
||||
pd.Show();
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
args.Proceed();
|
||||
activity.RunOnUiThread(DismissProgressDialog);
|
||||
activity.RunOnUiThread(pd.Dismiss);
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowProgressDialog(Activity activity)
|
||||
private static ProgressDialog ShowProgressDialog(Activity activity)
|
||||
{
|
||||
if (_progressDialog == null)
|
||||
{
|
||||
var pd = new ProgressDialog(activity);
|
||||
pd.SetMessage("Loading...Please wait...");
|
||||
pd.SetProgressStyle(ProgressDialogStyle.Spinner);
|
||||
_progressDialog = pd;
|
||||
}
|
||||
_progressDialog.Show();
|
||||
}
|
||||
|
||||
private void DismissProgressDialog()
|
||||
{
|
||||
_progressDialog.Dismiss();
|
||||
var pd = new ProgressDialog(activity);
|
||||
pd.SetMessage("Loading...Please wait...");
|
||||
pd.SetProgressStyle(ProgressDialogStyle.Spinner);
|
||||
return pd;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue