From aaf6ceb8ecbc71f6948c84b1a19fb83abfe8a418 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 25 Apr 2022 10:47:02 +0530 Subject: all: reformat with ktfmt 0.36 --- .../aps/ui/git/config/GitConfigActivity.kt | 23 ++++++------ .../aps/ui/git/config/GitServerConfigActivity.kt | 42 +++++++++++----------- 2 files changed, 32 insertions(+), 33 deletions(-) (limited to 'app/src/main/java/dev/msfjarvis/aps/ui/git/config') diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt index 959d9325..03c92313 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt @@ -88,9 +88,8 @@ class GitConfigActivity : BaseGitActivity() { binding.gitAbortRebase.alpha = if (needsAbort) 1.0f else 0.5f } binding.gitLog.setOnClickListener { - runCatching { startActivity(Intent(this, GitLogActivity::class.java)) }.onFailure { ex -> - logcat(ERROR) { "Failed to start GitLogActivity\n${ex}" } - } + runCatching { startActivity(Intent(this, GitLogActivity::class.java)) } + .onFailure { ex -> logcat(ERROR) { "Failed to start GitLogActivity\n${ex}" } } } binding.gitAbortRebase.setOnClickListener { lifecycleScope.launch { @@ -142,16 +141,16 @@ class GitConfigActivity : BaseGitActivity() { */ private fun headStatusMsg(repo: Repository): String { return runCatching { - val headRef = repo.getRef(Constants.HEAD) - if (headRef.isSymbolic) { - val branchName = headRef.target.name - val shortBranchName = Repository.shortenRefName(branchName) - getString(R.string.git_head_on_branch, shortBranchName) - } else { - val commitHash = headRef.objectId.abbreviate(8).name() - getString(R.string.git_head_detached, commitHash) + val headRef = repo.getRef(Constants.HEAD) + if (headRef.isSymbolic) { + val branchName = headRef.target.name + val shortBranchName = Repository.shortenRefName(branchName) + getString(R.string.git_head_on_branch, shortBranchName) + } else { + val commitHash = headRef.objectId.abbreviate(8).name() + getString(R.string.git_head_detached, commitHash) + } } - } .getOrElse { ex -> logcat(ERROR) { "Error getting HEAD reference\n${ex}" } getString(R.string.git_head_missing) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt index 6b1f30ea..e713a54e 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt @@ -240,24 +240,24 @@ class GitServerConfigActivity : BaseGitActivity() { .setCancelable(false) .setPositiveButton(R.string.dialog_delete) { dialog, _ -> runCatching { - lifecycleScope.launch { - val snackbar = - snackbar( - message = getString(R.string.delete_directory_progress_text), - length = Snackbar.LENGTH_INDEFINITE - ) - withContext(Dispatchers.IO) { localDir.deleteRecursively() } - snackbar.dismiss() - launchGitOperation(GitOp.CLONE) - .fold( - success = { - setResult(RESULT_OK) - finish() - }, - failure = { err -> promptOnErrorHandler(err) { finish() } } - ) + lifecycleScope.launch { + val snackbar = + snackbar( + message = getString(R.string.delete_directory_progress_text), + length = Snackbar.LENGTH_INDEFINITE + ) + withContext(Dispatchers.IO) { localDir.deleteRecursively() } + snackbar.dismiss() + launchGitOperation(GitOp.CLONE) + .fold( + success = { + setResult(RESULT_OK) + finish() + }, + failure = { err -> promptOnErrorHandler(err) { finish() } } + ) + } } - } .onFailure { e -> e.printStackTrace() MaterialAlertDialogBuilder(this).setMessage(e.message).show() @@ -268,11 +268,11 @@ class GitServerConfigActivity : BaseGitActivity() { .show() } else { runCatching { - // Silently delete & replace the lone .git folder if it exists - if (localDir.exists() && localDirFiles.size == 1 && localDirFiles[0].name == ".git") { - localDir.deleteRecursively() + // Silently delete & replace the lone .git folder if it exists + if (localDir.exists() && localDirFiles.size == 1 && localDirFiles[0].name == ".git") { + localDir.deleteRecursively() + } } - } .onFailure { e -> logcat(ERROR) { e.asLog() } MaterialAlertDialogBuilder(this).setMessage(e.message).show() -- cgit v1.2.3