@@ -3,67 +3,69 @@ package org.jetbrains.anko.appcompat.v7.coroutines
33
44
55import kotlin.coroutines.CoroutineContext
6- import kotlinx.coroutines.android.UI
6+ import kotlinx.coroutines.Dispatchers
77import kotlinx.coroutines.CoroutineScope
8+ import kotlinx.coroutines.GlobalScope
89import kotlinx.coroutines.launch
10+ import kotlinx.coroutines.CoroutineStart
911
1012fun android.support.v7.widget.ActionMenuView.onMenuItemClick (
11- context : CoroutineContext = UI ,
13+ context : CoroutineContext = Dispatchers . Main ,
1214 returnValue : Boolean = false,
1315 handler : suspend CoroutineScope .(item: android.view.MenuItem ? ) -> Unit
1416) {
1517 setOnMenuItemClickListener { item ->
16- launch(context) {
18+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
1719 handler(item)
1820 }
1921 returnValue
2022 }
2123}
2224
2325fun android.support.v7.widget.ActivityChooserView.onDismiss (
24- context : CoroutineContext = UI ,
26+ context : CoroutineContext = Dispatchers . Main ,
2527 handler : suspend CoroutineScope .() -> Unit
2628) {
2729 setOnDismissListener { ->
28- launch(context, block = handler)
30+ GlobalScope . launch(context, CoroutineStart . DEFAULT , block = handler)
2931 }
3032}
3133
3234fun android.support.v7.widget.FitWindowsFrameLayout.onFitSystemWindows (
33- context : CoroutineContext = UI ,
35+ context : CoroutineContext = Dispatchers . Main ,
3436 handler : suspend CoroutineScope .(insets: android.graphics.Rect ? ) -> Unit
3537) {
3638 setOnFitSystemWindowsListener { insets ->
37- launch(context) {
39+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
3840 handler(insets)
3941 }
4042 }
4143}
4244
4345fun android.support.v7.widget.SearchView.onClose (
44- context : CoroutineContext = UI ,
46+ context : CoroutineContext = Dispatchers . Main ,
4547 returnValue : Boolean = false,
4648 handler : suspend CoroutineScope .() -> Unit
4749) {
4850 setOnCloseListener { ->
49- launch(context, block = handler)
51+ GlobalScope . launch(context, CoroutineStart . DEFAULT , block = handler)
5052 returnValue
5153 }
5254}
5355
5456fun android.support.v7.widget.SearchView.onQueryTextFocusChange (
55- context : CoroutineContext = UI ,
57+ context : CoroutineContext = Dispatchers . Main ,
5658 handler : suspend CoroutineScope .(v: android.view.View , hasFocus: Boolean ) -> Unit
5759) {
5860 setOnQueryTextFocusChangeListener { v, hasFocus ->
59- launch(context) {
61+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
6062 handler(v, hasFocus)
6163 }
6264 }
6365}
6466
6567fun android.support.v7.widget.SearchView.onQueryTextListener (
66- context : CoroutineContext = UI ,
68+ context : CoroutineContext = Dispatchers . Main ,
6769 init : __SearchView_OnQueryTextListener .() -> Unit
6870) {
6971 val listener = __SearchView_OnQueryTextListener (context)
@@ -79,7 +81,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) :
7981 override fun onQueryTextSubmit (query : String? ) : Boolean {
8082 val returnValue = _onQueryTextSubmit_returnValue
8183 val handler = _onQueryTextSubmit ? : return returnValue
82- launch(context) {
84+ GlobalScope . launch(context) {
8385 handler(query)
8486 }
8587 return returnValue
@@ -99,7 +101,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) :
99101 override fun onQueryTextChange (newText : String? ) : Boolean {
100102 val returnValue = _onQueryTextChange_returnValue
101103 val handler = _onQueryTextChange ? : return returnValue
102- launch(context) {
104+ GlobalScope . launch(context) {
103105 handler(newText)
104106 }
105107 return returnValue
@@ -114,18 +116,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) :
114116 }
115117
116118}fun android.support.v7.widget.SearchView.onSearchClick(
117- context : CoroutineContext = UI ,
119+ context : CoroutineContext = Dispatchers . Main ,
118120 handler : suspend CoroutineScope .(v: android.view.View ? ) -> Unit
119121) {
120122 setOnSearchClickListener { v ->
121- launch(context) {
123+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
122124 handler(v)
123125 }
124126 }
125127}
126128
127129fun android.support.v7.widget.SearchView.onSuggestionListener (
128- context : CoroutineContext = UI ,
130+ context : CoroutineContext = Dispatchers . Main ,
129131 init : __SearchView_OnSuggestionListener .() -> Unit
130132) {
131133 val listener = __SearchView_OnSuggestionListener (context)
@@ -141,7 +143,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) :
141143 override fun onSuggestionSelect (position : Int ) : Boolean {
142144 val returnValue = _onSuggestionSelect_returnValue
143145 val handler = _onSuggestionSelect ? : return returnValue
144- launch(context) {
146+ GlobalScope . launch(context) {
145147 handler(position)
146148 }
147149 return returnValue
@@ -161,7 +163,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) :
161163 override fun onSuggestionClick (position : Int ) : Boolean {
162164 val returnValue = _onSuggestionClick_returnValue
163165 val handler = _onSuggestionClick ? : return returnValue
164- launch(context) {
166+ GlobalScope . launch(context) {
165167 handler(position)
166168 }
167169 return returnValue
@@ -176,24 +178,24 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) :
176178 }
177179
178180}fun android.support.v7.widget.Toolbar.onMenuItemClick(
179- context : CoroutineContext = UI ,
181+ context : CoroutineContext = Dispatchers . Main ,
180182 returnValue : Boolean = false ,
181183 handler : suspend CoroutineScope .(item: android.view.MenuItem ? ) -> Unit
182184) {
183185 setOnMenuItemClickListener { item ->
184- launch(context) {
186+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
185187 handler(item)
186188 }
187189 returnValue
188190 }
189191}
190192
191193fun android.support.v7.widget.ViewStubCompat.onInflate (
192- context : CoroutineContext = UI ,
194+ context : CoroutineContext = Dispatchers . Main ,
193195 handler : suspend CoroutineScope .(stub: android.support.v7.widget.ViewStubCompat ? , inflated: android.view.View ? ) -> Unit
194196) {
195197 setOnInflateListener { stub, inflated ->
196- launch(context) {
198+ GlobalScope . launch(context, CoroutineStart . DEFAULT ) {
197199 handler(stub, inflated)
198200 }
199201 }
0 commit comments