From e12c5cb69b38269408c8086240de557c2cfdd9da Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Thu, 8 Nov 2018 21:41:53 +0300 Subject: [PATCH] Fix compatibility with coroutines 1.0.0 --- .../src/main/java/ListenersWithCoroutines.kt | 48 +-- .../src/main/java/ListenersWithCoroutines.kt | 26 +- .../src/main/java/ListenersWithCoroutines.kt | 17 +- .../src/main/java/ListenersWithCoroutines.kt | 234 +++++++-------- .../src/main/java/ListenersWithCoroutines.kt | 242 ++++++++-------- .../src/main/java/ListenersWithCoroutines.kt | 258 +++++++++-------- .../src/main/java/ListenersWithCoroutines.kt | 266 ++++++++--------- .../src/main/java/ListenersWithCoroutines.kt | 266 ++++++++--------- .../src/main/java/ListenersWithCoroutines.kt | 274 +++++++++--------- .../complex_listener_coroutines.twig | 6 +- .../templates/simple_listener_coroutines.twig | 6 +- 11 files changed, 830 insertions(+), 813 deletions(-) diff --git a/anko/library/generated/appcompat-v7-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/appcompat-v7-coroutines/src/main/java/ListenersWithCoroutines.kt index 12fb041e..cfe3a544 100644 --- a/anko/library/generated/appcompat-v7-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/appcompat-v7-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,17 +3,19 @@ package org.jetbrains.anko.appcompat.v7.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart fun android.support.v7.widget.ActionMenuView.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -21,49 +23,49 @@ fun android.support.v7.widget.ActionMenuView.onMenuItemClick( } fun android.support.v7.widget.ActivityChooserView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.support.v7.widget.FitWindowsFrameLayout.onFitSystemWindows( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(insets: android.graphics.Rect?) -> Unit ) { setOnFitSystemWindowsListener { insets -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(insets) } } } fun android.support.v7.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.support.v7.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.support.v7.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -79,7 +81,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -99,7 +101,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -114,18 +116,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.support.v7.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.support.v7.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -141,7 +143,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -161,7 +163,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -176,12 +178,12 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.support.v7.widget.Toolbar.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -189,11 +191,11 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } fun android.support.v7.widget.ViewStubCompat.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.support.v7.widget.ViewStubCompat?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } diff --git a/anko/library/generated/design-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/design-coroutines/src/main/java/ListenersWithCoroutines.kt index fc2871ba..00ccb7f7 100644 --- a/anko/library/generated/design-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/design-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,23 +3,25 @@ package org.jetbrains.anko.design.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart fun android.support.design.widget.AppBarLayout.onOffsetChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(appBarLayout: android.support.design.widget.AppBarLayout?, verticalOffset: Int) -> Unit ) { addOnOffsetChangedListener { appBarLayout, verticalOffset -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(appBarLayout, verticalOffset) } } } fun android.support.design.widget.TabLayout.onTabSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TabLayout_OnTabSelectedListener.() -> Unit ) { val listener = __TabLayout_OnTabSelectedListener(context) @@ -34,7 +36,7 @@ class __TabLayout_OnTabSelectedListener(private val context: CoroutineContext) : override fun onTabSelected(tab: android.support.design.widget.TabLayout.Tab?) { val handler = _onTabSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(tab) } } @@ -50,7 +52,7 @@ class __TabLayout_OnTabSelectedListener(private val context: CoroutineContext) : override fun onTabUnselected(tab: android.support.design.widget.TabLayout.Tab?) { val handler = _onTabUnselected ?: return - launch(context) { + GlobalScope.launch(context) { handler(tab) } } @@ -66,7 +68,7 @@ class __TabLayout_OnTabSelectedListener(private val context: CoroutineContext) : override fun onTabReselected(tab: android.support.design.widget.TabLayout.Tab?) { val handler = _onTabReselected ?: return - launch(context) { + GlobalScope.launch(context) { handler(tab) } } @@ -78,12 +80,12 @@ class __TabLayout_OnTabSelectedListener(private val context: CoroutineContext) : } }fun android.support.design.widget.BottomNavigationView.onNavigationItemSelected( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnNavigationItemSelectedListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -91,7 +93,7 @@ class __TabLayout_OnTabSelectedListener(private val context: CoroutineContext) : } fun android.support.design.widget.CoordinatorLayout.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -106,7 +108,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -122,7 +124,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } diff --git a/anko/library/generated/recyclerview-v7-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/recyclerview-v7-coroutines/src/main/java/ListenersWithCoroutines.kt index 79c5a9c5..a3d28fc7 100644 --- a/anko/library/generated/recyclerview-v7-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/recyclerview-v7-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,12 +3,13 @@ package org.jetbrains.anko.recyclerview.v7.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch fun android.support.v7.widget.RecyclerView.onChildAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __RecyclerView_OnChildAttachStateChangeListener.() -> Unit ) { val listener = __RecyclerView_OnChildAttachStateChangeListener(context) @@ -23,7 +24,7 @@ class __RecyclerView_OnChildAttachStateChangeListener(private val context: Corou override fun onChildViewAttachedToWindow(view: android.view.View?) { val handler = _onChildViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(view) } } @@ -39,7 +40,7 @@ class __RecyclerView_OnChildAttachStateChangeListener(private val context: Corou override fun onChildViewDetachedFromWindow(view: android.view.View?) { val handler = _onChildViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(view) } } @@ -51,7 +52,7 @@ class __RecyclerView_OnChildAttachStateChangeListener(private val context: Corou } }fun android.support.v7.widget.RecyclerView.onItemTouchListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __RecyclerView_OnItemTouchListener.() -> Unit ) { val listener = __RecyclerView_OnItemTouchListener(context) @@ -67,7 +68,7 @@ class __RecyclerView_OnItemTouchListener(private val context: CoroutineContext) override fun onInterceptTouchEvent(rv: android.support.v7.widget.RecyclerView?, e: android.view.MotionEvent?) : Boolean { val returnValue = _onInterceptTouchEvent_returnValue val handler = _onInterceptTouchEvent ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(rv, e) } return returnValue @@ -86,7 +87,7 @@ class __RecyclerView_OnItemTouchListener(private val context: CoroutineContext) override fun onTouchEvent(rv: android.support.v7.widget.RecyclerView?, e: android.view.MotionEvent?) { val handler = _onTouchEvent ?: return - launch(context) { + GlobalScope.launch(context) { handler(rv, e) } } @@ -102,7 +103,7 @@ class __RecyclerView_OnItemTouchListener(private val context: CoroutineContext) override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) { val handler = _onRequestDisallowInterceptTouchEvent ?: return - launch(context) { + GlobalScope.launch(context) { handler(disallowIntercept) } } diff --git a/anko/library/generated/sdk15-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk15-coroutines/src/main/java/ListenersWithCoroutines.kt index f96daa8f..34c552fc 100644 --- a/anko/library/generated/sdk15-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk15-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,23 +3,25 @@ package org.jetbrains.anko.sdk15.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -34,7 +36,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -50,7 +52,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -62,7 +64,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -77,7 +79,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -93,7 +95,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -109,7 +111,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -121,7 +123,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -136,7 +138,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -152,7 +154,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -168,7 +170,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -184,7 +186,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -196,18 +198,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -222,7 +224,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -238,7 +240,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -250,34 +252,34 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -285,23 +287,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -309,12 +311,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -322,12 +324,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -335,12 +337,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -348,23 +350,23 @@ fun android.view.View.onLongClick( } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -372,7 +374,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -387,7 +389,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -403,7 +405,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -415,18 +417,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -441,7 +443,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -457,7 +459,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -469,23 +471,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -493,7 +495,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -508,7 +510,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -524,7 +526,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -536,45 +538,45 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -582,12 +584,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -595,95 +597,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -699,7 +701,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -719,7 +721,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -734,18 +736,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -761,7 +763,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -781,7 +783,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -796,7 +798,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -811,7 +813,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -827,7 +829,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -843,7 +845,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -855,25 +857,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -888,7 +890,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -902,7 +904,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -912,23 +914,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -936,34 +938,34 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -971,33 +973,33 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/library/generated/sdk19-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk19-coroutines/src/main/java/ListenersWithCoroutines.kt index 16bef3ae..bd627e83 100644 --- a/anko/library/generated/sdk19-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk19-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,23 +3,25 @@ package org.jetbrains.anko.sdk19.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -34,7 +36,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -50,7 +52,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -62,7 +64,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -77,7 +79,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -93,7 +95,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -109,7 +111,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -121,7 +123,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -136,7 +138,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -152,7 +154,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -168,7 +170,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -184,7 +186,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -196,18 +198,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -222,7 +224,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -238,7 +240,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -250,34 +252,34 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -285,23 +287,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -309,12 +311,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -322,12 +324,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -335,12 +337,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -348,23 +350,23 @@ fun android.view.View.onLongClick( } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -372,7 +374,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -387,7 +389,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -403,7 +405,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -415,18 +417,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -441,7 +443,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -457,7 +459,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -469,23 +471,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -493,7 +495,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -508,7 +510,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -524,7 +526,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -536,54 +538,54 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.AutoCompleteTextView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -591,12 +593,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -604,95 +606,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -708,7 +710,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -728,7 +730,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -743,18 +745,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -770,7 +772,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -790,7 +792,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -805,7 +807,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -820,7 +822,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -836,7 +838,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -852,7 +854,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -864,25 +866,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -897,7 +899,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -911,7 +913,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -921,23 +923,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -945,34 +947,34 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -980,12 +982,12 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onInfo( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnInfoListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -993,33 +995,33 @@ fun android.widget.VideoView.onInfo( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/library/generated/sdk21-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk21-coroutines/src/main/java/ListenersWithCoroutines.kt index 6b4c0cea..a20c1c12 100644 --- a/anko/library/generated/sdk21-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk21-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,24 +3,26 @@ package org.jetbrains.anko.sdk21.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart import android.view.WindowInsets fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -35,7 +37,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -51,7 +53,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -63,7 +65,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -78,7 +80,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -94,7 +96,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -110,7 +112,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -122,7 +124,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -137,7 +139,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -153,7 +155,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -169,7 +171,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -185,7 +187,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -197,18 +199,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -223,7 +225,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -239,7 +241,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -251,12 +253,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.media.tv.TvView.onUnhandledInputEvent( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(event: android.view.InputEvent?) -> Unit ) { setOnUnhandledInputEventListener { event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(event) } returnValue @@ -264,12 +266,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } fun android.view.View.onApplyWindowInsets( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: WindowInsets, handler: suspend CoroutineScope.(v: android.view.View?, insets: android.view.WindowInsets?) -> Unit ) { setOnApplyWindowInsetsListener { v, insets -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, insets) } returnValue @@ -277,34 +279,34 @@ fun android.view.View.onApplyWindowInsets( } fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -312,23 +314,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -336,12 +338,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -349,12 +351,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -362,12 +364,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -375,23 +377,23 @@ fun android.view.View.onLongClick( } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -399,7 +401,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -414,7 +416,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -430,7 +432,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -442,18 +444,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -468,7 +470,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -484,7 +486,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -496,12 +498,12 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.ActionMenuView.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -509,23 +511,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -533,7 +535,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -548,7 +550,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -564,7 +566,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -576,54 +578,54 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.AutoCompleteTextView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -631,12 +633,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -644,95 +646,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -748,7 +750,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -768,7 +770,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -783,18 +785,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -810,7 +812,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -830,7 +832,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -845,7 +847,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -860,7 +862,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -876,7 +878,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -892,7 +894,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -904,25 +906,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -937,7 +939,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -951,7 +953,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -961,23 +963,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -985,23 +987,23 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.Toolbar.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -1009,23 +1011,23 @@ fun android.widget.Toolbar.onMenuItemClick( } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1033,12 +1035,12 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onInfo( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnInfoListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1046,33 +1048,33 @@ fun android.widget.VideoView.onInfo( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/library/generated/sdk23-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk23-coroutines/src/main/java/ListenersWithCoroutines.kt index bf6c4463..4b930a01 100644 --- a/anko/library/generated/sdk23-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk23-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,24 +3,26 @@ package org.jetbrains.anko.sdk23.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart import android.view.WindowInsets fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -35,7 +37,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -51,7 +53,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -63,7 +65,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -78,7 +80,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -94,7 +96,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -110,7 +112,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -122,7 +124,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -137,7 +139,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -153,7 +155,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -169,7 +171,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -185,7 +187,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -197,18 +199,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -223,7 +225,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -239,7 +241,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -251,12 +253,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.media.tv.TvView.onUnhandledInputEvent( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(event: android.view.InputEvent?) -> Unit ) { setOnUnhandledInputEventListener { event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(event) } returnValue @@ -264,12 +266,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } fun android.view.View.onApplyWindowInsets( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: WindowInsets, handler: suspend CoroutineScope.(v: android.view.View?, insets: android.view.WindowInsets?) -> Unit ) { setOnApplyWindowInsetsListener { v, insets -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, insets) } returnValue @@ -277,23 +279,23 @@ fun android.view.View.onApplyWindowInsets( } fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onContextClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnContextClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -301,23 +303,23 @@ fun android.view.View.onContextClick( } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -325,23 +327,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -349,12 +351,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -362,12 +364,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -375,12 +377,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -388,34 +390,34 @@ fun android.view.View.onLongClick( } fun android.view.View.onScrollChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) -> Unit ) { setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, scrollX, scrollY, oldScrollX, oldScrollY) } } } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -423,7 +425,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -438,7 +440,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -454,7 +456,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -466,18 +468,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -492,7 +494,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -508,7 +510,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -520,12 +522,12 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.ActionMenuView.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -533,23 +535,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -557,7 +559,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -572,7 +574,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -588,7 +590,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -600,54 +602,54 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.AutoCompleteTextView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -655,12 +657,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -668,95 +670,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -772,7 +774,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -792,7 +794,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -807,18 +809,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -834,7 +836,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -854,7 +856,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -869,7 +871,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -884,7 +886,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -900,7 +902,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -916,7 +918,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -928,25 +930,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -961,7 +963,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -975,7 +977,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -985,23 +987,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -1009,23 +1011,23 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.Toolbar.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -1033,23 +1035,23 @@ fun android.widget.Toolbar.onMenuItemClick( } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1057,12 +1059,12 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onInfo( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnInfoListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1070,33 +1072,33 @@ fun android.widget.VideoView.onInfo( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/library/generated/sdk25-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk25-coroutines/src/main/java/ListenersWithCoroutines.kt index 93eb8519..a2766a84 100644 --- a/anko/library/generated/sdk25-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk25-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,24 +3,26 @@ package org.jetbrains.anko.sdk25.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart import android.view.WindowInsets fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -35,7 +37,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -51,7 +53,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -63,7 +65,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -78,7 +80,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -94,7 +96,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -110,7 +112,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -122,7 +124,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -137,7 +139,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -153,7 +155,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -169,7 +171,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -185,7 +187,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -197,18 +199,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -223,7 +225,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -239,7 +241,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -251,12 +253,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.media.tv.TvView.onUnhandledInputEvent( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(event: android.view.InputEvent?) -> Unit ) { setOnUnhandledInputEventListener { event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(event) } returnValue @@ -264,12 +266,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } fun android.view.View.onApplyWindowInsets( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: WindowInsets, handler: suspend CoroutineScope.(v: android.view.View?, insets: android.view.WindowInsets?) -> Unit ) { setOnApplyWindowInsetsListener { v, insets -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, insets) } returnValue @@ -277,23 +279,23 @@ fun android.view.View.onApplyWindowInsets( } fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onContextClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnContextClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -301,23 +303,23 @@ fun android.view.View.onContextClick( } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -325,23 +327,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -349,12 +351,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -362,12 +364,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -375,12 +377,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -388,34 +390,34 @@ fun android.view.View.onLongClick( } fun android.view.View.onScrollChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) -> Unit ) { setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, scrollX, scrollY, oldScrollX, oldScrollY) } } } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -423,7 +425,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -438,7 +440,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -454,7 +456,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -466,18 +468,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -492,7 +494,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -508,7 +510,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -520,12 +522,12 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.ActionMenuView.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -533,23 +535,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -557,7 +559,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -572,7 +574,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -588,7 +590,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -600,54 +602,54 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.AutoCompleteTextView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -655,12 +657,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -668,95 +670,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -772,7 +774,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -792,7 +794,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -807,18 +809,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -834,7 +836,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -854,7 +856,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -869,7 +871,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -884,7 +886,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -900,7 +902,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -916,7 +918,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -928,25 +930,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -961,7 +963,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -975,7 +977,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -985,23 +987,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -1009,23 +1011,23 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.Toolbar.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -1033,23 +1035,23 @@ fun android.widget.Toolbar.onMenuItemClick( } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1057,12 +1059,12 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onInfo( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnInfoListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1070,33 +1072,33 @@ fun android.widget.VideoView.onInfo( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/library/generated/sdk27-coroutines/src/main/java/ListenersWithCoroutines.kt b/anko/library/generated/sdk27-coroutines/src/main/java/ListenersWithCoroutines.kt index 3ef8e819..d8633d20 100644 --- a/anko/library/generated/sdk27-coroutines/src/main/java/ListenersWithCoroutines.kt +++ b/anko/library/generated/sdk27-coroutines/src/main/java/ListenersWithCoroutines.kt @@ -3,24 +3,26 @@ package org.jetbrains.anko.sdk27.coroutines import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.android.UI +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.CoroutineStart import android.view.WindowInsets fun android.view.View.onLayoutChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) -> Unit ) { addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) } } } fun android.view.View.onAttachStateChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __View_OnAttachStateChangeListener.() -> Unit ) { val listener = __View_OnAttachStateChangeListener(context) @@ -35,7 +37,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewAttachedToWindow(v: android.view.View) { val handler = _onViewAttachedToWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -51,7 +53,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) override fun onViewDetachedFromWindow(v: android.view.View) { val handler = _onViewDetachedFromWindow ?: return - launch(context) { + GlobalScope.launch(context) { handler(v) } } @@ -63,7 +65,7 @@ class __View_OnAttachStateChangeListener(private val context: CoroutineContext) } }fun android.widget.TextView.textChangedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __TextWatcher.() -> Unit ) { val listener = __TextWatcher(context) @@ -78,7 +80,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { val handler = _beforeTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, count, after) } } @@ -94,7 +96,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { val handler = _onTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s, start, before, count) } } @@ -110,7 +112,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa override fun afterTextChanged(s: android.text.Editable?) { val handler = _afterTextChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(s) } } @@ -122,7 +124,7 @@ class __TextWatcher(private val context: CoroutineContext) : android.text.TextWa } }fun android.gesture.GestureOverlayView.onGestureListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGestureListener.() -> Unit ) { val listener = __GestureOverlayView_OnGestureListener(context) @@ -137,7 +139,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureStarted(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -153,7 +155,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGesture(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGesture ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -169,7 +171,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureEnded(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -185,7 +187,7 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte override fun onGestureCancelled(overlay: android.gesture.GestureOverlayView?, event: android.view.MotionEvent?) { val handler = _onGestureCancelled ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay, event) } } @@ -197,18 +199,18 @@ class __GestureOverlayView_OnGestureListener(private val context: CoroutineConte } }fun android.gesture.GestureOverlayView.onGesturePerformed( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(overlay: android.gesture.GestureOverlayView?, gesture: android.gesture.Gesture?) -> Unit ) { addOnGesturePerformedListener { overlay, gesture -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(overlay, gesture) } } } fun android.gesture.GestureOverlayView.onGesturingListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __GestureOverlayView_OnGesturingListener.() -> Unit ) { val listener = __GestureOverlayView_OnGesturingListener(context) @@ -223,7 +225,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingStarted(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingStarted ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -239,7 +241,7 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon override fun onGesturingEnded(overlay: android.gesture.GestureOverlayView?) { val handler = _onGesturingEnded ?: return - launch(context) { + GlobalScope.launch(context) { handler(overlay) } } @@ -251,12 +253,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } }fun android.media.tv.TvView.onUnhandledInputEvent( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(event: android.view.InputEvent?) -> Unit ) { setOnUnhandledInputEventListener { event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(event) } returnValue @@ -264,12 +266,12 @@ class __GestureOverlayView_OnGesturingListener(private val context: CoroutineCon } fun android.view.View.onApplyWindowInsets( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: WindowInsets, handler: suspend CoroutineScope.(v: android.view.View?, insets: android.view.WindowInsets?) -> Unit ) { setOnApplyWindowInsetsListener { v, insets -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, insets) } returnValue @@ -277,12 +279,12 @@ fun android.view.View.onApplyWindowInsets( } fun android.view.View.onCapturedPointer( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(view: android.view.View?, event: android.view.MotionEvent?) -> Unit ) { setOnCapturedPointerListener { view, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, event) } returnValue @@ -290,23 +292,23 @@ fun android.view.View.onCapturedPointer( } fun android.view.View.onClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.view.View.onContextClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnContextClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -314,23 +316,23 @@ fun android.view.View.onContextClick( } fun android.view.View.onCreateContextMenu( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(menu: android.view.ContextMenu?, v: android.view.View?, menuInfo: android.view.ContextMenu.ContextMenuInfo?) -> Unit ) { setOnCreateContextMenuListener { menu, v, menuInfo -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(menu, v, menuInfo) } } } fun android.view.View.onDrag( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.DragEvent) -> Unit ) { setOnDragListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -338,23 +340,23 @@ fun android.view.View.onDrag( } fun android.view.View.onFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.view.View.onGenericMotion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnGenericMotionListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -362,12 +364,12 @@ fun android.view.View.onGenericMotion( } fun android.view.View.onHover( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnHoverListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -375,12 +377,12 @@ fun android.view.View.onHover( } fun android.view.View.onKey( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, keyCode: Int, event: android.view.KeyEvent?) -> Unit ) { setOnKeyListener { v, keyCode, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, keyCode, event) } returnValue @@ -388,12 +390,12 @@ fun android.view.View.onKey( } fun android.view.View.onLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnLongClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } returnValue @@ -401,34 +403,34 @@ fun android.view.View.onLongClick( } fun android.view.View.onScrollChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) -> Unit ) { setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, scrollX, scrollY, oldScrollX, oldScrollY) } } } fun android.view.View.onSystemUiVisibilityChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(visibility: Int) -> Unit ) { setOnSystemUiVisibilityChangeListener { visibility -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(visibility) } } } fun android.view.View.onTouch( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.view.View, event: android.view.MotionEvent) -> Unit ) { setOnTouchListener { v, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, event) } returnValue @@ -436,7 +438,7 @@ fun android.view.View.onTouch( } fun android.view.ViewGroup.onHierarchyChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __ViewGroup_OnHierarchyChangeListener.() -> Unit ) { val listener = __ViewGroup_OnHierarchyChangeListener(context) @@ -451,7 +453,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewAdded(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewAdded ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -467,7 +469,7 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex override fun onChildViewRemoved(parent: android.view.View?, child: android.view.View?) { val handler = _onChildViewRemoved ?: return - launch(context) { + GlobalScope.launch(context) { handler(parent, child) } } @@ -479,18 +481,18 @@ class __ViewGroup_OnHierarchyChangeListener(private val context: CoroutineContex } }fun android.view.ViewStub.onInflate( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(stub: android.view.ViewStub?, inflated: android.view.View?) -> Unit ) { setOnInflateListener { stub, inflated -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(stub, inflated) } } } fun android.widget.AbsListView.onScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AbsListView_OnScrollListener.() -> Unit ) { val listener = __AbsListView_OnScrollListener(context) @@ -505,7 +507,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScrollStateChanged(view: android.widget.AbsListView?, scrollState: Int) { val handler = _onScrollStateChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, scrollState) } } @@ -521,7 +523,7 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an override fun onScroll(view: android.widget.AbsListView?, firstVisibleItem: Int, visibleItemCount: Int, totalItemCount: Int) { val handler = _onScroll ?: return - launch(context) { + GlobalScope.launch(context) { handler(view, firstVisibleItem, visibleItemCount, totalItemCount) } } @@ -533,12 +535,12 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } }fun android.widget.ActionMenuView.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -546,23 +548,23 @@ class __AbsListView_OnScrollListener(private val context: CoroutineContext) : an } fun android.widget.AdapterView.onItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } } } fun android.widget.AdapterView.onItemLongClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) -> Unit ) { setOnItemLongClickListener { p0, p1, p2, p3 -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(p0, p1, p2, p3) } returnValue @@ -570,7 +572,7 @@ fun android.widget.AdapterView.onItemLongClick( } fun android.widget.AdapterView.onItemSelectedListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __AdapterView_OnItemSelectedListener.() -> Unit ) { val listener = __AdapterView_OnItemSelectedListener(context) @@ -585,7 +587,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onItemSelected(p0: android.widget.AdapterView<*>?, p1: android.view.View?, p2: Int, p3: Long) { val handler = _onItemSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0, p1, p2, p3) } } @@ -601,7 +603,7 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext override fun onNothingSelected(p0: android.widget.AdapterView<*>?) { val handler = _onNothingSelected ?: return - launch(context) { + GlobalScope.launch(context) { handler(p0) } } @@ -613,65 +615,65 @@ class __AdapterView_OnItemSelectedListener(private val context: CoroutineContext } }fun android.widget.AutoCompleteTextView.onDismiss( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDismissListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.CalendarView.onDateChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.CalendarView?, year: Int, month: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangeListener { view, year, month, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, month, dayOfMonth) } } } fun android.widget.Chronometer.onChronometerTick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(chronometer: android.widget.Chronometer?) -> Unit ) { setOnChronometerTickListener { chronometer -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(chronometer) } } } fun android.widget.CompoundButton.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(buttonView: android.widget.CompoundButton?, isChecked: Boolean) -> Unit ) { setOnCheckedChangeListener { buttonView, isChecked -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(buttonView, isChecked) } } } fun android.widget.DatePicker.onDateChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.DatePicker?, year: Int, monthOfYear: Int, dayOfMonth: Int) -> Unit ) { setOnDateChangedListener { view, year, monthOfYear, dayOfMonth -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, year, monthOfYear, dayOfMonth) } } } fun android.widget.ExpandableListView.onChildClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, childPosition: Int, id: Long) -> Unit ) { setOnChildClickListener { parent, v, groupPosition, childPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, childPosition, id) } returnValue @@ -679,12 +681,12 @@ fun android.widget.ExpandableListView.onChildClick( } fun android.widget.ExpandableListView.onGroupClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(parent: android.widget.ExpandableListView?, v: android.view.View?, groupPosition: Int, id: Long) -> Unit ) { setOnGroupClickListener { parent, v, groupPosition, id -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(parent, v, groupPosition, id) } returnValue @@ -692,95 +694,95 @@ fun android.widget.ExpandableListView.onGroupClick( } fun android.widget.ExpandableListView.onGroupCollapse( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupCollapseListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.ExpandableListView.onGroupExpand( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(groupPosition: Int) -> Unit ) { setOnGroupExpandListener { groupPosition -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(groupPosition) } } } fun android.widget.NumberPicker.onScroll( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.NumberPicker?, scrollState: Int) -> Unit ) { setOnScrollListener { view, scrollState -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, scrollState) } } } fun android.widget.NumberPicker.onValueChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(picker: android.widget.NumberPicker?, oldVal: Int, newVal: Int) -> Unit ) { setOnValueChangedListener { picker, oldVal, newVal -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(picker, oldVal, newVal) } } } fun android.widget.RadioGroup.onCheckedChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(group: android.widget.RadioGroup?, checkedId: Int) -> Unit ) { setOnCheckedChangeListener { group, checkedId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(group, checkedId) } } } fun android.widget.RatingBar.onRatingBarChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(ratingBar: android.widget.RatingBar?, rating: Float, fromUser: Boolean) -> Unit ) { setOnRatingBarChangeListener { ratingBar, rating, fromUser -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(ratingBar, rating, fromUser) } } } fun android.widget.SearchView.onClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.() -> Unit ) { setOnCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) returnValue } } fun android.widget.SearchView.onQueryTextFocusChange( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View, hasFocus: Boolean) -> Unit ) { setOnQueryTextFocusChangeListener { v, hasFocus -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, hasFocus) } } } fun android.widget.SearchView.onQueryTextListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnQueryTextListener.() -> Unit ) { val listener = __SearchView_OnQueryTextListener(context) @@ -796,7 +798,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextSubmit(query: String?) : Boolean { val returnValue = _onQueryTextSubmit_returnValue val handler = _onQueryTextSubmit ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(query) } return returnValue @@ -816,7 +818,7 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : override fun onQueryTextChange(newText: String?) : Boolean { val returnValue = _onQueryTextChange_returnValue val handler = _onQueryTextChange ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(newText) } return returnValue @@ -831,18 +833,18 @@ class __SearchView_OnQueryTextListener(private val context: CoroutineContext) : } }fun android.widget.SearchView.onSearchClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnSearchClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.SearchView.onSuggestionListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SearchView_OnSuggestionListener.() -> Unit ) { val listener = __SearchView_OnSuggestionListener(context) @@ -858,7 +860,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionSelect(position: Int) : Boolean { val returnValue = _onSuggestionSelect_returnValue val handler = _onSuggestionSelect ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -878,7 +880,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : override fun onSuggestionClick(position: Int) : Boolean { val returnValue = _onSuggestionClick_returnValue val handler = _onSuggestionClick ?: return returnValue - launch(context) { + GlobalScope.launch(context) { handler(position) } return returnValue @@ -893,7 +895,7 @@ class __SearchView_OnSuggestionListener(private val context: CoroutineContext) : } }fun android.widget.SeekBar.onSeekBarChangeListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SeekBar_OnSeekBarChangeListener.() -> Unit ) { val listener = __SeekBar_OnSeekBarChangeListener(context) @@ -908,7 +910,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onProgressChanged(seekBar: android.widget.SeekBar?, progress: Int, fromUser: Boolean) { val handler = _onProgressChanged ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar, progress, fromUser) } } @@ -924,7 +926,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStartTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStartTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -940,7 +942,7 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : override fun onStopTrackingTouch(seekBar: android.widget.SeekBar?) { val handler = _onStopTrackingTouch ?: return - launch(context) { + GlobalScope.launch(context) { handler(seekBar) } } @@ -952,25 +954,25 @@ class __SeekBar_OnSeekBarChangeListener(private val context: CoroutineContext) : } }fun android.widget.SlidingDrawer.onDrawerClose( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerCloseListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerOpen( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.() -> Unit ) { setOnDrawerOpenListener { -> - launch(context, block = handler) + GlobalScope.launch(context, CoroutineStart.DEFAULT, block = handler) } } fun android.widget.SlidingDrawer.onDrawerScrollListener( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, init: __SlidingDrawer_OnDrawerScrollListener.() -> Unit ) { val listener = __SlidingDrawer_OnDrawerScrollListener(context) @@ -985,7 +987,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollStarted() { val handler = _onScrollStarted ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollStarted( @@ -999,7 +1001,7 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte override fun onScrollEnded() { val handler = _onScrollEnded ?: return - launch(context, block = handler) + GlobalScope.launch(context, block = handler) } fun onScrollEnded( @@ -1009,23 +1011,23 @@ class __SlidingDrawer_OnDrawerScrollListener(private val context: CoroutineConte } }fun android.widget.TabHost.onTabChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(tabId: String?) -> Unit ) { setOnTabChangedListener { tabId -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(tabId) } } } fun android.widget.TextView.onEditorAction( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(v: android.widget.TextView?, actionId: Int, event: android.view.KeyEvent?) -> Unit ) { setOnEditorActionListener { v, actionId, event -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v, actionId, event) } returnValue @@ -1033,23 +1035,23 @@ fun android.widget.TextView.onEditorAction( } fun android.widget.TimePicker.onTimeChanged( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(view: android.widget.TimePicker?, hourOfDay: Int, minute: Int) -> Unit ) { setOnTimeChangedListener { view, hourOfDay, minute -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(view, hourOfDay, minute) } } } fun android.widget.Toolbar.onMenuItemClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(item: android.view.MenuItem?) -> Unit ) { setOnMenuItemClickListener { item -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(item) } returnValue @@ -1057,23 +1059,23 @@ fun android.widget.Toolbar.onMenuItemClick( } fun android.widget.VideoView.onCompletion( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnCompletionListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.VideoView.onError( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnErrorListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1081,12 +1083,12 @@ fun android.widget.VideoView.onError( } fun android.widget.VideoView.onInfo( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, returnValue: Boolean = false, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?, what: Int, extra: Int) -> Unit ) { setOnInfoListener { mp, what, extra -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp, what, extra) } returnValue @@ -1094,33 +1096,33 @@ fun android.widget.VideoView.onInfo( } fun android.widget.VideoView.onPrepared( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(mp: android.media.MediaPlayer?) -> Unit ) { setOnPreparedListener { mp -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(mp) } } } fun android.widget.ZoomControls.onZoomInClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomInClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } } fun android.widget.ZoomControls.onZoomOutClick( - context: CoroutineContext = UI, + context: CoroutineContext = Dispatchers.Main, handler: suspend CoroutineScope.(v: android.view.View?) -> Unit ) { setOnZoomOutClickListener { v -> - launch(context) { + GlobalScope.launch(context, CoroutineStart.DEFAULT) { handler(v) } } diff --git a/anko/props/templates/complex_listener_coroutines.twig b/anko/props/templates/complex_listener_coroutines.twig index 2ba75f49..a348b6c4 100644 --- a/anko/props/templates/complex_listener_coroutines.twig +++ b/anko/props/templates/complex_listener_coroutines.twig @@ -1,5 +1,5 @@ fun {{ setter.receiver }}.{{ setter.methodName }}Listener( - context: {{ imported("kotlin.coroutines.CoroutineContext") }} = {{ imported("kotlinx.coroutines.android.UI") }}, + context: {{ imported("kotlin.coroutines.CoroutineContext") }} = {{ imported("kotlinx.coroutines.Dispatchers.Main") }}, init: {{ setter.listener }}.() -> Unit ) { val listener = {{ setter.listener }}(context) @@ -16,11 +16,11 @@ class {{ helperClassName }}(private val context: {{ imported("kotlin.coroutines. {% if (method.returnType != "Unit") %}val returnValue = _{{ method.varName }}_returnValue {% endif %}val handler = _{{ method.varName }} ?: return{% if (method.returnType != "Unit") %} returnValue{% endif %} {% if (method.hasArgs == true) -%} - {{ imported("kotlinx.coroutines.launch") }}(context) { + {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context) { handler({{ method.argNames }}) } {%- else -%} - {{ imported("kotlinx.coroutines.launch") }}(context, block = handler) + {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context, block = handler) {%- endif %}{% if (method.returnType != "Unit") %} return returnValue{% endif %} } diff --git a/anko/props/templates/simple_listener_coroutines.twig b/anko/props/templates/simple_listener_coroutines.twig index 44e846a0..3e4969fa 100644 --- a/anko/props/templates/simple_listener_coroutines.twig +++ b/anko/props/templates/simple_listener_coroutines.twig @@ -1,15 +1,15 @@ fun {{ receiver }}.{{ name }}( - context: {{ imported("kotlin.coroutines.CoroutineContext") }} = {{ imported("kotlinx.coroutines.android.UI") }}, + context: {{ imported("kotlin.coroutines.CoroutineContext") }} = {{ imported("kotlinx.coroutines.Dispatchers.Main") }}, {% if (returnType != "Unit") %}returnValue: {{ imported(returnType) }}{% if (returnDefaultValue != "") %} = {{ returnDefaultValue }}{% endif %}, {% endif %}handler: suspend {{ imported("kotlinx.coroutines.CoroutineScope") }}.({{ args }}) -> Unit ) { {{setter}} { {{ argNames }} -> {% if (hasArgs == true) -%} - {{ imported("kotlinx.coroutines.launch") }}(context) { + {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context, {{ imported("kotlinx.coroutines.CoroutineStart.DEFAULT") }}) { handler({{ argNames }}) } {%- else -%} - {{ imported("kotlinx.coroutines.launch") }}(context, block = handler) + {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context, {{ imported("kotlinx.coroutines.CoroutineStart.DEFAULT") }}, block = handler) {%- endif %}{% if (returnType != "Unit") %} returnValue{% endif %} }