From 273917269ac99d95f6c2937d0a0df8bfb8d3d35a Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Sat, 25 Dec 2021 21:22:15 +0100 Subject: [PATCH] make the code easier to read --- .../pro/dialogs/CustomPeriodPickerDialog.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/CustomPeriodPickerDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/CustomPeriodPickerDialog.kt index 153a2a07d..6afa3eaeb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/CustomPeriodPickerDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/CustomPeriodPickerDialog.kt @@ -4,7 +4,10 @@ import android.app.Activity import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.pro.R -import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.extensions.hideKeyboard +import com.simplemobiletools.commons.extensions.setupDialogStuff +import com.simplemobiletools.commons.extensions.showKeyboard +import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.helpers.DAY_SECONDS import com.simplemobiletools.commons.helpers.MONTH_SECONDS import com.simplemobiletools.commons.helpers.WEEK_SECONDS @@ -36,7 +39,13 @@ class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int private fun confirmReminder() { val value = view.dialog_custom_period_value.value val type = view.dialog_radio_view.checkedRadioButtonId - val period = calculatePeriod(Integer.valueOf(if (value.isEmpty()) "0" else value), type) + val periodValue = if (value.isEmpty()) { + "0" + } else { + value + } + + val period = calculatePeriod(Integer.valueOf(periodValue), type) callback(period) activity.hideKeyboard() dialog.dismiss()