forked from Clancey/MonoDroid.Dialog
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDialogActivity.cs
59 lines (52 loc) · 1.75 KB
/
DialogActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Linq;
using Android.App;
namespace Android.Dialog
{
public class DialogActivity : ListActivity
{
public RootElement Root
{
get { return _dialogAdapter == null ? null : _dialogAdapter.Root; }
set
{
value.Context = this;
value.ValueChanged -= HandleValueChangedEvent;
value.ValueChanged += HandleValueChangedEvent;
if (_dialogAdapter != null)
{
_dialogAdapter.DeregisterListView();
}
ListAdapter = _dialogAdapter = new DialogAdapter(this, value, ListView);
}
}
private DialogAdapter _dialogAdapter;
public void HandleValueChangedEvents(EventHandler eventHandler)
{
foreach (var element in Root.Sections.SelectMany(section => section))
{
if (element is EntryElement)
(element as EntryElement).Changed += eventHandler;
if (element is BooleanElement)
(element as BooleanElement).Changed += eventHandler;
if (element is CheckboxElement)
(element as CheckboxElement).Changed += eventHandler;
}
}
public event EventHandler ValueChanged;
private void HandleValueChangedEvent(object sender, EventArgs args)
{
if (ValueChanged != null)
ValueChanged(sender, args);
}
public override Java.Lang.Object OnRetainNonConfigurationInstance()
{
return null;
}
public void ReloadData()
{
if (Root == null) return;
_dialogAdapter.ReloadData();
}
}
}