From 47a02a93a09d4ffe866f41be783b86b795b48985 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 17 Mar 2022 18:45:00 +0100 Subject: [PATCH] shorten method to comply with detekt Signed-off-by: Andy Scherzinger --- .../talk/ui/dialog/SetStatusDialogFragment.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 30271b244..57584222a 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -212,17 +212,8 @@ class SetStatusDialogFragment : binding.emoji.disableKeyboardInput(popup) binding.emoji.forceSingleEmoji() - val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item) - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) - adapter.add(getString(R.string.dontClear)) - adapter.add(getString(R.string.thirtyMinutes)) - adapter.add(getString(R.string.oneHour)) - adapter.add(getString(R.string.fourHours)) - adapter.add(getString(R.string.today)) - adapter.add(getString(R.string.thisWeek)) - binding.clearStatusAfterSpinner.apply { - this.adapter = adapter + this.adapter = createClearTimesArrayAdapter() onItemSelectedListener = object : OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { setClearStatusAfterValue(position) @@ -244,6 +235,18 @@ class SetStatusDialogFragment : } } + private fun createClearTimesArrayAdapter(): ArrayAdapter { + val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item) + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + adapter.add(getString(R.string.dontClear)) + adapter.add(getString(R.string.thirtyMinutes)) + adapter.add(getString(R.string.oneHour)) + adapter.add(getString(R.string.fourHours)) + adapter.add(getString(R.string.today)) + adapter.add(getString(R.string.thisWeek)) + return adapter + } + @Suppress("ComplexMethod") private fun setClearStatusAfterValue(item: Int) {