diff options
| author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-08-05 19:02:24 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-05 19:02:24 +0530 |
| commit | 14c44bf584cb7d13ada46b264419efca923ed65c (patch) | |
| tree | b22c8a9a7be7934927ed20fa9b2060c877953082 /app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt | |
| parent | 12a83e5c36b82e42dda6a58248e2879fde9c3ac8 (diff) | |
| download | HardenedPass-14c44bf584cb7d13ada46b264419efca923ed65c.tar.gz HardenedPass-14c44bf584cb7d13ada46b264419efca923ed65c.zip | |
Remove GitAsyncTask and replace with non-blocking coroutines (#865)
Co-authored-by: Fabian Henneke <fabian@henneke.me>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt index c3a46fd7..121a3402 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt @@ -8,19 +8,21 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem +import androidx.lifecycle.lifecycleScope import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.zeapo.pwdstore.R import com.zeapo.pwdstore.UserPreference import com.zeapo.pwdstore.utils.PasswordRepository +import kotlinx.coroutines.launch open class GitOperationActivity : BaseGitActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) when (intent.extras?.getInt(REQUEST_ARG_OP)) { - REQUEST_PULL -> syncRepository(REQUEST_PULL) - REQUEST_PUSH -> syncRepository(REQUEST_PUSH) - REQUEST_SYNC -> syncRepository(REQUEST_SYNC) + REQUEST_PULL -> lifecycleScope.launch { syncRepository(REQUEST_PULL) } + REQUEST_PUSH -> lifecycleScope.launch { syncRepository(REQUEST_PUSH) } + REQUEST_SYNC -> lifecycleScope.launch { syncRepository(REQUEST_SYNC) } else -> { setResult(RESULT_CANCELED) finish() @@ -54,7 +56,7 @@ open class GitOperationActivity : BaseGitActivity() { * * @param operation the operation to execute can be REQUEST_PULL or REQUEST_PUSH */ - private fun syncRepository(operation: Int) { + private suspend fun syncRepository(operation: Int) { if (serverUser.isEmpty() || serverHostname.isEmpty() || url.isNullOrEmpty()) MaterialAlertDialogBuilder(this) .setMessage(getString(R.string.set_information_dialog_text)) |
