make the code easier to read

This commit is contained in:
Tibor Kaputa 2021-12-25 21:22:15 +01:00 committed by GitHub
parent 0b8193593f
commit 273917269a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -4,7 +4,10 @@ import android.app.Activity
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R 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.DAY_SECONDS
import com.simplemobiletools.commons.helpers.MONTH_SECONDS import com.simplemobiletools.commons.helpers.MONTH_SECONDS
import com.simplemobiletools.commons.helpers.WEEK_SECONDS import com.simplemobiletools.commons.helpers.WEEK_SECONDS
@ -36,7 +39,13 @@ class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int
private fun confirmReminder() { private fun confirmReminder() {
val value = view.dialog_custom_period_value.value val value = view.dialog_custom_period_value.value
val type = view.dialog_radio_view.checkedRadioButtonId 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) callback(period)
activity.hideKeyboard() activity.hideKeyboard()
dialog.dismiss() dialog.dismiss()