forked from Clancey/MonoDroid.Dialog
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDialogListFragment.cs
62 lines (52 loc) · 1.76 KB
/
DialogListFragment.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
60
61
62
using System;
using Android.Support.V4.App;
using Android.Text.Style;
namespace Android.Dialog
{
public class DialogListFragment : ListFragment
{
private RootElement _root = null;
public RootElement Root
{
get { return DialogAdapter == null ? null : DialogAdapter.Root; }
set
{
value.Context = Activity;
value.ValueChanged -= HandleValueChangedEvent;
value.ValueChanged += HandleValueChangedEvent;
if (ListAdapter == null)
_root = value;
else
DialogAdapter.Root = value;
}
}
public override Views.View OnCreateView(Views.LayoutInflater p0, Views.ViewGroup p1, OS.Bundle p2)
{
ListAdapter = DialogAdapter;
return base.OnCreateView(p0, p1, p2);
}
public override void OnViewCreated(Views.View p0, OS.Bundle p1)
{
if (DialogAdapter == null)
{
ListAdapter = DialogAdapter = new DialogAdapter(Activity, _root, ListView);
_root = null;
}
DialogAdapter.List = ListView;
DialogAdapter.RegisterListView();
base.OnViewCreated(p0, p1);
}
public DialogAdapter DialogAdapter { get; set; }
public event EventHandler ValueChanged;
private void HandleValueChangedEvent(object sender, EventArgs args)
{
if (ValueChanged != null)
ValueChanged(sender, args);
}
public void ReloadData()
{
if (Root == null) return;
DialogAdapter.ReloadData();
}
}
}