forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewEventExtensions.Android.cs
More file actions
52 lines (40 loc) · 1.15 KB
/
Copy pathViewEventExtensions.Android.cs
File metadata and controls
52 lines (40 loc) · 1.15 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using Uno.Disposables;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Uno.Extensions;
namespace Uno.UI
{
internal static class ViewEventExtensions
{
public static View InitializeClick(this View view, bool isClickable, ICollection<IDisposable> subscriptions, Action<object, EventArgs> selector)
{
if (isClickable)
{
view.Clickable = isClickable;
EventHandler handler = (s, e) => selector(s, e);
view.Click += handler;
subscriptions.Add(Disposable.Create(() => view.Click -= handler));
}
return view;
}
public static View InitializeLongClick(this View view, bool isLongClickable, ICollection<IDisposable> subscriptions, Action<object, View.LongClickEventArgs> selector)
{
if (isLongClickable)
{
view.LongClickable = isLongClickable;
EventHandler<View.LongClickEventArgs> handler = (s, e) => selector(s, e);
view.LongClick += handler;
subscriptions.Add(Disposable.Create(() => view.LongClick -= handler));
}
return view;
}
}
}