From 45753583ee58515e2ec3d96fa934e032cdc82a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 6 Jan 2020 15:56:23 +0100 Subject: [PATCH] [UI/Login] Fix back button not working on Login Chooser. --- .../edziennik/ui/modules/login/LoginActivity.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginActivity.kt index 104c221f..9c2d2a34 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/login/LoginActivity.kt @@ -39,22 +39,22 @@ class LoginActivity : AppCompatActivity(), CoroutineScope { val loginStores = mutableListOf() override fun onBackPressed() { - val destination = nav.currentDestination - if (destination != null && destination.id == R.id.loginSyncErrorFragment) { + val destination = nav.currentDestination ?: run { + nav.navigateUp() return } - if (destination != null && destination.id == R.id.loginProgressFragment) { + if (destination.id == R.id.loginSyncErrorFragment) return - } - if (destination != null && destination.id == R.id.loginSyncFragment) { + if (destination.id == R.id.loginProgressFragment) return - } - if (destination != null && destination.id == R.id.loginChooserFragment && !app.config.loginFinished) { + if (destination.id == R.id.loginSyncFragment) + return + if (destination.id == R.id.loginChooserFragment) { setResult(Activity.RESULT_CANCELED) finish() return } - if (destination != null && destination.id == R.id.loginSummaryFragment) { + if (destination.id == R.id.loginSummaryFragment) { MaterialAlertDialogBuilder(this) .setTitle(R.string.are_you_sure) .setMessage(R.string.login_cancel_confirmation)