From 57125f696e971ec299c6315ba426bf63ae1efb5f Mon Sep 17 00:00:00 2001 From: GKF Date: Wed, 19 Jun 2019 10:31:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/base/BaseFragment.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/base/BaseFragment.kt b/app/src/main/java/io/legado/app/base/BaseFragment.kt index 0a35d8a1f..7c02f1bd3 100644 --- a/app/src/main/java/io/legado/app/base/BaseFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseFragment.kt @@ -7,8 +7,12 @@ import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import io.legado.app.utils.setIconColor +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.cancel -abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId) { +abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId), + CoroutineScope by MainScope() { var supportToolbar: Toolbar? = null private set @@ -16,6 +20,10 @@ abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId val menuInflater: MenuInflater get() = SupportMenuInflater(requireContext()) + override fun onDestroy() { + super.onDestroy() + cancel() + } fun setSupportToolbar(toolbar: Toolbar) { supportToolbar = toolbar