From 14c44bf584cb7d13ada46b264419efca923ed65c Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 5 Aug 2020 19:02:24 +0530 Subject: Remove GitAsyncTask and replace with non-blocking coroutines (#865) Co-authored-by: Fabian Henneke --- app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt') diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt index 6c87e0f6..4830b2c8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt @@ -10,6 +10,7 @@ import android.view.View import androidx.core.content.edit import androidx.core.os.postDelayed import androidx.core.widget.doOnTextChanged +import androidx.lifecycle.lifecycleScope import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar import com.zeapo.pwdstore.R @@ -20,6 +21,7 @@ import com.zeapo.pwdstore.utils.PasswordRepository import com.zeapo.pwdstore.utils.PreferenceKeys import com.zeapo.pwdstore.utils.viewBinding import java.io.IOException +import kotlinx.coroutines.launch /** * Activity that encompasses both the initial clone as well as editing the server config for future @@ -171,7 +173,7 @@ class GitServerConfigActivity : BaseGitActivity() { .setPositiveButton(R.string.dialog_delete) { dialog, _ -> try { localDir.deleteRecursively() - launchGitOperation(REQUEST_CLONE) + lifecycleScope.launch { launchGitOperation(REQUEST_CLONE) } } catch (e: IOException) { // TODO Handle the exception correctly if we are unable to delete the directory... e.printStackTrace() @@ -201,7 +203,7 @@ class GitServerConfigActivity : BaseGitActivity() { e.printStackTrace() MaterialAlertDialogBuilder(this).setMessage(e.message).show() } - launchGitOperation(REQUEST_CLONE) + lifecycleScope.launch { launchGitOperation(REQUEST_CLONE) } } } } -- cgit v1.2.3