improved browser get token task

This commit is contained in:
Mariotaku Lee 2016-12-16 14:24:44 +08:00
parent fa298f4a83
commit e1e6ee9a44
1 changed files with 9 additions and 8 deletions

View File

@ -63,11 +63,6 @@ class BrowserSignInActivity : BaseActivity() {
private var requestToken: OAuthToken? = null private var requestToken: OAuthToken? = null
private var task: GetRequestTokenTask? = null private var task: GetRequestTokenTask? = null
public override fun onDestroy() {
loaderManager.destroyLoader(0)
super.onDestroy()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
android.R.id.home -> { android.R.id.home -> {
@ -98,11 +93,17 @@ class BrowserSignInActivity : BaseActivity() {
getRequestToken() getRequestToken()
} }
public override fun onDestroy() {
if (task?.status == AsyncTask.Status.RUNNING) {
task?.cancel(true)
}
super.onDestroy()
}
private fun getRequestToken() { private fun getRequestToken() {
if (requestToken != null || task != null && task!!.status == AsyncTask.Status.RUNNING) if (requestToken != null || task?.status == AsyncTask.Status.RUNNING) return
return
task = GetRequestTokenTask(this) task = GetRequestTokenTask(this)
AsyncTaskUtils.executeTask<GetRequestTokenTask, Any>(task) AsyncTaskUtils.executeTask(task)
} }
private fun loadUrl(url: String) { private fun loadUrl(url: String) {