parent
75c99dbe7d
commit
d460a5ede3
@ -0,0 +1,24 @@ |
||||
package io.legado.app.base |
||||
|
||||
import android.os.Bundle |
||||
import androidx.fragment.app.DialogFragment |
||||
import kotlinx.coroutines.CoroutineScope |
||||
import kotlinx.coroutines.Dispatchers |
||||
import kotlinx.coroutines.Job |
||||
import kotlin.coroutines.CoroutineContext |
||||
|
||||
abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { |
||||
override val coroutineContext: CoroutineContext |
||||
get() = job + Dispatchers.Main |
||||
private lateinit var job: Job |
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
job = Job() |
||||
} |
||||
|
||||
override fun onDestroy() { |
||||
super.onDestroy() |
||||
job.cancel() |
||||
} |
||||
} |
Loading…
Reference in new issue