shorten method to comply with detekt

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-03-17 18:45:00 +01:00
parent 4685bced16
commit 47a02a93a0
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -212,17 +212,8 @@ class SetStatusDialogFragment :
binding.emoji.disableKeyboardInput(popup) binding.emoji.disableKeyboardInput(popup)
binding.emoji.forceSingleEmoji() binding.emoji.forceSingleEmoji()
val adapter = ArrayAdapter<String>(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 { binding.clearStatusAfterSpinner.apply {
this.adapter = adapter this.adapter = createClearTimesArrayAdapter()
onItemSelectedListener = object : OnItemSelectedListener { onItemSelectedListener = object : OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
setClearStatusAfterValue(position) setClearStatusAfterValue(position)
@ -244,6 +235,18 @@ class SetStatusDialogFragment :
} }
} }
private fun createClearTimesArrayAdapter(): ArrayAdapter<String> {
val adapter = ArrayAdapter<String>(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") @Suppress("ComplexMethod")
private fun setClearStatusAfterValue(item: Int) { private fun setClearStatusAfterValue(item: Int) {