update the end date/time of event when start changes, keep same duration
This commit is contained in:
parent
4bf3a8a576
commit
c6082a5ac4
|
@ -471,6 +471,11 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
event_start_time.text = Formatter.getTime(this, mEventStartDateTime)
|
event_start_time.text = Formatter.getTime(this, mEventStartDateTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateEndTexts() {
|
||||||
|
updateEndDateText()
|
||||||
|
updateEndTimeText()
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateEndDateText() {
|
private fun updateEndDateText() {
|
||||||
event_end_date.text = Formatter.getDate(applicationContext, mEventEndDateTime)
|
event_end_date.text = Formatter.getDate(applicationContext, mEventEndDateTime)
|
||||||
}
|
}
|
||||||
|
@ -530,14 +535,14 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
|
|
||||||
private fun dateSet(year: Int, month: Int, day: Int, isStart: Boolean) {
|
private fun dateSet(year: Int, month: Int, day: Int, isStart: Boolean) {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
|
val diff = mEventEndDateTime.seconds() - mEventStartDateTime.seconds()
|
||||||
|
|
||||||
mEventStartDateTime = mEventStartDateTime.withDate(year, month + 1, day)
|
mEventStartDateTime = mEventStartDateTime.withDate(year, month + 1, day)
|
||||||
updateStartDateText()
|
updateStartDateText()
|
||||||
if (mEventStartDateTime.isAfter(mEventEndDateTime)) {
|
|
||||||
mEventEndDateTime = mEventStartDateTime
|
|
||||||
updateEndDateText()
|
|
||||||
updateEndTimeText()
|
|
||||||
}
|
|
||||||
checkRepeatRule()
|
checkRepeatRule()
|
||||||
|
|
||||||
|
mEventEndDateTime = mEventStartDateTime.plusSeconds(diff)
|
||||||
|
updateEndTexts()
|
||||||
} else {
|
} else {
|
||||||
mEventEndDateTime = mEventEndDateTime.withDate(year, month + 1, day)
|
mEventEndDateTime = mEventEndDateTime.withDate(year, month + 1, day)
|
||||||
updateEndDateText()
|
updateEndDateText()
|
||||||
|
@ -546,12 +551,13 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
|
|
||||||
private fun timeSet(hours: Int, minutes: Int, isStart: Boolean) {
|
private fun timeSet(hours: Int, minutes: Int, isStart: Boolean) {
|
||||||
if (isStart) {
|
if (isStart) {
|
||||||
|
val diff = mEventEndDateTime.seconds() - mEventStartDateTime.seconds()
|
||||||
|
|
||||||
mEventStartDateTime = mEventStartDateTime.withHourOfDay(hours).withMinuteOfHour(minutes)
|
mEventStartDateTime = mEventStartDateTime.withHourOfDay(hours).withMinuteOfHour(minutes)
|
||||||
updateStartTimeText()
|
updateStartTimeText()
|
||||||
if (mEventStartDateTime.isAfter(mEventEndDateTime)) {
|
|
||||||
mEventEndDateTime = mEventStartDateTime
|
mEventEndDateTime = mEventStartDateTime.plusSeconds(diff)
|
||||||
updateEndTimeText()
|
updateEndTexts()
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mEventEndDateTime = mEventEndDateTime.withHourOfDay(hours).withMinuteOfHour(minutes)
|
mEventEndDateTime = mEventEndDateTime.withHourOfDay(hours).withMinuteOfHour(minutes)
|
||||||
updateEndTimeText()
|
updateEndTimeText()
|
||||||
|
|
Loading…
Reference in New Issue