update a couple repeat interval values

This commit is contained in:
tibbi 2017-04-23 15:01:18 +02:00
parent b8d6c8c83c
commit 5f8166b95f
2 changed files with 14 additions and 7 deletions

View File

@ -183,10 +183,15 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private fun checkRepetitionLimitText() { private fun checkRepetitionLimitText() {
event_repetition_limit.text = if (mRepeatLimit == 0) { event_repetition_limit.text = if (mRepeatLimit == 0) {
event_repetition_limit_label.text = getString(R.string.repeat)
resources.getString(R.string.forever) resources.getString(R.string.forever)
} else { } else if (mRepeatLimit > 0) {
event_repetition_limit_label.text = getString(R.string.repeat_till)
val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit) val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit)
Formatter.getFullDate(applicationContext, repeatLimitDateTime) Formatter.getFullDate(applicationContext, repeatLimitDateTime)
} else {
event_repetition_limit_label.text = getString(R.string.repeat)
"${-mRepeatLimit} ${getString(R.string.times)}"
} }
} }

View File

@ -27,10 +27,11 @@ class RepeatTypePickerDialog(val activity: Activity, var repeatLimit: Int, val s
repeat_type_date.setOnClickListener { showRepetitionLimitDialog() } repeat_type_date.setOnClickListener { showRepetitionLimitDialog() }
repeat_type_forever.setOnClickListener { callback(0); dialog.dismiss() } repeat_type_forever.setOnClickListener { callback(0); dialog.dismiss() }
repeat_type_count.setOnClickListener { dialog_radio_view.check(R.id.repeat_type_x_times) } repeat_type_count.setOnClickListener { dialog_radio_view.check(R.id.repeat_type_x_times) }
dialog_radio_view.check(getCheckedItem())
} }
if (repeatLimit < startTS) view.dialog_radio_view.check(getCheckedItem())
if (repeatLimit in 1..startTS)
repeatLimit = startTS repeatLimit = startTS
updateRepeatLimitText() updateRepeatLimitText()
@ -47,14 +48,15 @@ class RepeatTypePickerDialog(val activity: Activity, var repeatLimit: Int, val s
private fun getCheckedItem(): Int { private fun getCheckedItem(): Int {
return if (repeatLimit > 0) return if (repeatLimit > 0)
R.id.repeat_type_till_date R.id.repeat_type_till_date
else if (repeatLimit < 0) else if (repeatLimit < 0) {
R.id.repeat_type_count view.repeat_type_count.setText((-repeatLimit).toString())
else R.id.repeat_type_x_times
} else
R.id.repeat_type_forever R.id.repeat_type_forever
} }
private fun updateRepeatLimitText() { private fun updateRepeatLimitText() {
if (repeatLimit == 0) if (repeatLimit <= 0)
repeatLimit = (System.currentTimeMillis() / 1000).toInt() repeatLimit = (System.currentTimeMillis() / 1000).toInt()
val repeatLimitDateTime = Formatter.getDateTimeFromTS(repeatLimit) val repeatLimitDateTime = Formatter.getDateTimeFromTS(repeatLimit)