-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservice.go
76 lines (74 loc) · 2.11 KB
/
service.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package faithdroid
type FService struct {
a IActivity
}
func (s *FService) GetContext() string {
return "Service"
}
func StartService(a IActivity, f func()) *FService {
fnId := NewToken()
fn := func(string) string {
go f()
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnId] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[a.GetMyActivity().UI].ViewSetAttr("Service", "OnCreate", fnId)
return &FService{}
}
func Service(a IActivity) *FService {
return &FService{a: a}
}
func (f *FService) QuitButton(title string) *FService {
GlobalVars.UIs[f.a.GetMyActivity().UI].ViewSetAttr("Service", "QuitButton", title)
return f
}
func (v *FService) Title(s string) *FService {
GlobalVars.UIs[v.a.GetMyActivity().UI].ViewSetAttr("Service", "Title", s)
return v
}
func (v *FService) SubTitle(s string) *FService {
GlobalVars.UIs[v.a.GetMyActivity().UI].ViewSetAttr("Service", "SubTitle", s)
return v
}
func (v *FService) OnCreate(f func()) *FService {
fnID := NewToken()
fn := func(string) string {
f()
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnID] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[v.a.GetMyActivity().UI].ViewSetAttr("Service", "OnCreate", fnID)
return v
}
func (v *FService) OnQuit(f func()) *FService {
fnID := NewToken()
fn := func(string) string {
f()
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnID] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[v.a.GetMyActivity().UI].ViewSetAttr("Service", "OnQuit", fnID)
return v
}
func (f *FService) Show() *FService {
GlobalVars.UIs[f.a.GetMyActivity().UI].ViewSetAttr("Service", "Show", "")
return f
}
func (f *FService) FinishAllActivity() *FService {
GlobalVars.UIs[f.a.GetMyActivity().UI].ViewSetAttr("Service", "FinishAllActivity", "")
return f
}
func (f *FService) KillAll() *FService {
GlobalVars.UIs[f.a.GetMyActivity().UI].ViewSetAttr("Service", "KillAll", "")
return f
}
func (f *FService) Stop() *FService {
GlobalVars.UIs[f.a.GetMyActivity().UI].ViewSetAttr("Service", "Stop", "")
return f
}