From dbc646a146242bcf605299b3219e0800b9222d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Thu, 30 Sep 2021 15:35:05 -0400 Subject: [PATCH] migration cleanup Change-Id: I3af1d23f9b8f658e9f199eac2ef5810030e14f8d --- .../fragments/AccountMigrationFragment.kt | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.kt b/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.kt index b96364ca8..7cd106503 100644 --- a/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.kt +++ b/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.kt @@ -61,21 +61,19 @@ class AccountMigrationFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, parent: ViewGroup?, savedInstanceState: Bundle?): View { - binding = FragAccountMigrationBinding.inflate(inflater, parent, false) - return binding!!.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - binding!!.ringPassword.setOnEditorActionListener { v: TextView, actionId: Int, event: KeyEvent? -> - actionId == EditorInfo.IME_ACTION_NEXT && checkPassword(v, null) - } - binding!!.ringPassword.onFocusChangeListener = View.OnFocusChangeListener { v: View, hasFocus: Boolean -> - if (!hasFocus) { - checkPassword(v as TextView, null) + return FragAccountMigrationBinding.inflate(inflater, parent, false).apply { + ringPassword.setOnEditorActionListener { v: TextView, actionId: Int, event: KeyEvent? -> + actionId == EditorInfo.IME_ACTION_NEXT && checkPassword(v, null) } - } - binding!!.ringMigrateBtn.setOnClickListener { initAccountMigration(binding!!.ringPassword.text.toString()) } - binding!!.deleteBtn.setOnClickListener { initAccountDelete() } + ringPassword.onFocusChangeListener = View.OnFocusChangeListener { v: View, hasFocus: Boolean -> + if (!hasFocus) { + checkPassword(v as TextView, null) + } + } + ringMigrateBtn.setOnClickListener { initAccountMigration(ringPassword.text.toString()) } + deleteBtn.setOnClickListener { initAccountDelete() } + binding = this + }.root } override fun onResume() { @@ -150,17 +148,13 @@ class AccountMigrationFragment : Fragment() { private fun handleMigrationState(newState: String) { migratingAccount = false + mProgress?.let { progress -> + progress.dismiss() + mProgress = null + } if (TextUtils.isEmpty(newState)) { - if (mProgress != null) { - mProgress!!.dismiss() - mProgress = null - } return } - if (mProgress != null) { - mProgress!!.dismiss() - mProgress = null - } val dialogBuilder: AlertDialog.Builder = MaterialAlertDialogBuilder(requireContext()) dialogBuilder.setPositiveButton(android.R.string.ok) { dialog: DialogInterface?, id: Int -> } var success = false -- GitLab