1
0
Fork 0

For #3834 - Initialize job in init

master
Emily Kager 2019-07-01 15:23:41 -07:00 committed by Emily Kager
parent 50052c9b9b
commit bed926c317
2 changed files with 4 additions and 15 deletions

View File

@ -11,15 +11,10 @@ import kotlinx.coroutines.Job
/**
* [RecyclerView.Adapter] with a [Job] for coroutines.
* The adapterJob is setup when the adapter is attached to a RecyclerView and canceled when detached.
* The adapterJob is setup when the adapter is initialized to a RecyclerView and canceled when detached.
*/
abstract class AdapterWithJob<VH : RecyclerView.ViewHolder> : RecyclerView.Adapter<VH>() {
protected lateinit var adapterJob: Job
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
super.onAttachedToRecyclerView(recyclerView)
adapterJob = Job()
}
protected var adapterJob: Job = Job()
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
super.onDetachedFromRecyclerView(recyclerView)
@ -29,17 +24,12 @@ abstract class AdapterWithJob<VH : RecyclerView.ViewHolder> : RecyclerView.Adapt
/**
* [ListAdapter] with a [Job] for coroutines.
* The adapterJob is setup when the adapter is attached to a RecyclerView and canceled when detached.
* The adapterJob is setup when the adapter is initialized to a RecyclerView and canceled when detached.
*/
abstract class ListAdapterWithJob<T, VH : RecyclerView.ViewHolder>(
diffCallback: DiffUtil.ItemCallback<T>
) : ListAdapter<T, VH>(diffCallback) {
protected lateinit var adapterJob: Job
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
super.onAttachedToRecyclerView(recyclerView)
adapterJob = Job()
}
protected var adapterJob: Job = Job()
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
super.onDetachedFromRecyclerView(recyclerView)

View File

@ -405,7 +405,6 @@
<dialog
android:id="@+id/shareFragment"
android:name="org.mozilla.fenix.share.ShareFragment"
android:label="fragment_share"
tools:layout="@layout/fragment_share" >
<argument
android:name="url"