File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
library/src/main/java/de/tobiasschuerg/weekview/view Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -200,14 +200,27 @@ internal class WeekBackgroundView constructor(context: Context) : View(context)
200
200
}
201
201
202
202
fun updateTimes (startTime : LocalTime , endTime : LocalTime ) {
203
- if (startTime.isAfter(endTime)) throw IllegalArgumentException ()
203
+ if (startTime.isAfter(endTime)) {
204
+ throw IllegalArgumentException (" Start time $startTime must be before end time $endTime " )
205
+ }
206
+ var timesHaveChanged = false
204
207
if (startTime.isBefore(this .startTime)) {
205
208
this .startTime = startTime.truncatedTo(ChronoUnit .HOURS )
209
+ timesHaveChanged = true
206
210
}
207
211
if (endTime.isAfter(this .endTime)) {
208
- this .endTime = endTime.truncatedTo(ChronoUnit .HOURS ).plusHours(1 )
212
+ if (endTime.isBefore(LocalTime .of(23 , 0 ))) {
213
+ this .endTime = endTime.truncatedTo(ChronoUnit .HOURS ).plusHours(1 )
214
+ } else {
215
+ this .endTime = LocalTime .MAX
216
+ }
217
+ timesHaveChanged = true
218
+ }
219
+ if (this .startTime.isAfter(this .endTime)) throw IllegalArgumentException ()
220
+
221
+ if (timesHaveChanged) {
222
+ requestLayout()
209
223
}
210
- requestLayout()
211
224
}
212
225
213
226
private fun getDurationMinutes (): Long {
You can’t perform that action at this time.
0 commit comments