issue 4 - removed 'save' button from config screen, it now just saves whenever a checkbox is clicked (thanks correll)

This commit is contained in:
mgroves 2011-04-07 23:39:13 -04:00
parent d9959b0867
commit cbe17a7175
4 changed files with 32 additions and 34 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Android.App;
@ -14,7 +15,6 @@ namespace MonoStockPortfolio.Activites.ConfigScreen
public class ConfigActivity : Activity, IConfigView
{
[LazyView(Resource.Id.configList)] private ListView ConfigList;
[LazyView(Resource.Id.btnSaveConfig)] private Button SaveConfigButton;
[IoC] IConfigPresenter _presenter;
@ -36,9 +36,27 @@ namespace MonoStockPortfolio.Activites.ConfigScreen
WireUpEvents();
}
void WireUpEvents()
private void WireUpEvents()
{
SaveConfigButton.Click += SaveConfigButton_Click;
ConfigList.ItemClick += ConfigList_ItemClick;
}
void ConfigList_ItemClick(object sender, ItemEventArgs e)
{
SaveConfiguration();
}
void SaveConfiguration()
{
var checkedItems = new List<StockDataItem>();
for(int i =0;i<ConfigList.Count;i++)
{
if (ConfigList.IsItemChecked(i))
{
checkedItems.Add((StockDataItem) i);
}
}
_presenter.SaveConfig(checkedItems);
}
#region IConfigView members
@ -65,18 +83,5 @@ namespace MonoStockPortfolio.Activites.ConfigScreen
}
#endregion
void SaveConfigButton_Click(object sender, System.EventArgs e)
{
var checkedItems = new List<StockDataItem>();
for(int i =0;i<ConfigList.Count;i++)
{
if (ConfigList.IsItemChecked(i))
{
checkedItems.Add((StockDataItem) i);
}
}
_presenter.SaveConfig(checkedItems);
}
}
}

View file

@ -58,32 +58,29 @@ namespace MonoStockPortfolio
// aapt resource value: 0x7f050002
public const int addPositionTicker = 2131034114;
// aapt resource value: 0x7f050008
public const int btnAddPortfolio = 2131034120;
// aapt resource value: 0x7f050007
public const int btnAddPortfolio = 2131034119;
// aapt resource value: 0x7f05000a
public const int btnAddPosition = 2131034122;
// aapt resource value: 0x7f050009
public const int btnAddPosition = 2131034121;
// aapt resource value: 0x7f050001
public const int btnSave = 2131034113;
// aapt resource value: 0x7f050006
public const int btnSaveConfig = 2131034118;
public const int configList = 2131034118;
// aapt resource value: 0x7f050007
public const int configList = 2131034119;
// aapt resource value: 0x7f050009
public const int portfolioList = 2131034121;
// aapt resource value: 0x7f050008
public const int portfolioList = 2131034120;
// aapt resource value: 0x7f050000
public const int portfolioName = 2131034112;
// aapt resource value: 0x7f05000b
public const int quoteHeaderLayout = 2131034123;
// aapt resource value: 0x7f05000a
public const int quoteHeaderLayout = 2131034122;
// aapt resource value: 0x7f05000c
public const int quoteListview = 2131034124;
// aapt resource value: 0x7f05000b
public const int quoteListview = 2131034123;
private Id()
{

View file

@ -26,7 +26,6 @@
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Price per share" />

View file

@ -4,9 +4,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:text="Save" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/btnSaveConfig" />
<ListView android:id="@+id/configList"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />