From e1e6ee9a449c0808aab7c62e50f59b981f3eb058 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 16 Dec 2016 14:24:44 +0800 Subject: [PATCH] improved browser get token task --- .../twidere/activity/BrowserSignInActivity.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt index cc103e685..f51f127f4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt @@ -63,11 +63,6 @@ class BrowserSignInActivity : BaseActivity() { private var requestToken: OAuthToken? = null private var task: GetRequestTokenTask? = null - public override fun onDestroy() { - loaderManager.destroyLoader(0) - super.onDestroy() - } - override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { android.R.id.home -> { @@ -98,11 +93,17 @@ class BrowserSignInActivity : BaseActivity() { getRequestToken() } + public override fun onDestroy() { + if (task?.status == AsyncTask.Status.RUNNING) { + task?.cancel(true) + } + super.onDestroy() + } + private fun getRequestToken() { - if (requestToken != null || task != null && task!!.status == AsyncTask.Status.RUNNING) - return + if (requestToken != null || task?.status == AsyncTask.Status.RUNNING) return task = GetRequestTokenTask(this) - AsyncTaskUtils.executeTask(task) + AsyncTaskUtils.executeTask(task) } private fun loadUrl(url: String) {