Skip to content

Commit 5a4695f

Browse files
committed
Fix build errors
1 parent 6cfadf2 commit 5a4695f

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

core/src/main/java/com/alamkanak/weekview/CalendarExtensions.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ internal fun Calendar.plusDays(days: Int): Calendar {
4343
}
4444
}
4545

46+
internal fun Calendar.plusHours(hours: Int): Calendar {
47+
return copy().apply {
48+
add(Calendar.HOUR_OF_DAY, hours)
49+
}
50+
}
51+
4652
internal fun Calendar.addDays(days: Int) {
4753
add(Calendar.DATE, days)
4854
}
@@ -53,6 +59,12 @@ internal fun Calendar.minusDays(days: Int): Calendar {
5359
}
5460
}
5561

62+
internal fun Calendar.minusHours(hours: Int): Calendar {
63+
return copy().apply {
64+
add(Calendar.HOUR_OF_DAY, hours * -1)
65+
}
66+
}
67+
5668
internal fun Calendar.plusMillis(millis: Int): Calendar {
5769
return copy().apply {
5870
add(Calendar.MILLISECOND, millis)

core/src/main/java/com/alamkanak/weekview/WeekView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ class WeekView @JvmOverloads constructor(
354354
var headerBottomShadowColor: Int
355355
@RequiresApi(api = 29)
356356
get() = viewState.headerBackgroundWithShadowPaint.shadowLayerColor
357+
@RequiresApi(api = 29)
357358
set(value) {
358359
val paint = viewState.headerBackgroundWithShadowPaint
359360
paint.setShadowLayer(headerBottomShadowRadius.toFloat(), 0f, 0f, value)
@@ -367,6 +368,7 @@ class WeekView @JvmOverloads constructor(
367368
var headerBottomShadowRadius: Int
368369
@RequiresApi(api = 29)
369370
get() = viewState.headerBackgroundWithShadowPaint.shadowLayerRadius.roundToInt()
371+
@RequiresApi(api = 29)
370372
set(value) {
371373
val paint = viewState.headerBackgroundWithShadowPaint
372374
paint.setShadowLayer(value.toFloat(), 0f, 0f, headerBottomShadowColor)

core/src/test/java/com/alamkanak/weekview/WeekViewEventTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class WeekViewEventTest {
2424

2525
@Test
2626
fun `single-day event is recognized correctly`() {
27-
val startTime = (today() + Days(1)).withHour(6).withMinutes(0)
28-
val endTime = startTime + Hours(10)
27+
val startTime = (today().plusDays(1)).withHour(6).withMinutes(0)
28+
val endTime = startTime.plusHours(10)
2929

3030
val originalEvent = Mocks.weekViewItem(startTime, endTime)
3131

@@ -39,8 +39,8 @@ class WeekViewEventTest {
3939

4040
@Test
4141
fun `two-day event is recognized correctly`() {
42-
val startTime = (today() + Days(1)).withHour(14).withMinutes(0)
43-
val endTime = (today() + Days(2)).withHour(14).withMinutes(0)
42+
val startTime = (today().plusDays(1)).withHour(14).withMinutes(0)
43+
val endTime = (today().plusDays(2)).withHour(14).withMinutes(0)
4444

4545
val originalEvent = Mocks.weekViewItem(startTime, endTime)
4646
val eventChips = factory.create(listOf(originalEvent), viewState)
@@ -58,8 +58,8 @@ class WeekViewEventTest {
5858

5959
@Test
6060
fun `multi-day event is recognized correctly`() {
61-
val startTime = (today() + Days(1)).withHour(14).withMinutes(0)
62-
val endTime = (today() + Days(3)).withHour(1).withMinutes(0)
61+
val startTime = (today().plusDays(1)).withHour(14).withMinutes(0)
62+
val endTime = (today().plusDays(3)).withHour(1).withMinutes(0)
6363

6464
val originalEvent = Mocks.weekViewItem(startTime, endTime)
6565
val eventChips = factory.create(listOf(originalEvent), viewState)
@@ -79,11 +79,11 @@ class WeekViewEventTest {
7979
@Test
8080
fun `non-colliding events are recognized correctly`() {
8181
val firstStartTime = now()
82-
val firstEndTime = firstStartTime + Hours(1)
82+
val firstEndTime = firstStartTime.plusHours(1)
8383
val first = Mocks.weekViewItem(firstStartTime, firstEndTime)
8484

85-
val secondStartTime = firstStartTime + Hours(2)
86-
val secondEndTime = secondStartTime + Hours(1)
85+
val secondStartTime = firstStartTime.plusHours(2)
86+
val secondEndTime = secondStartTime.plusHours(1)
8787
val second = Mocks.weekViewItem(secondStartTime, secondEndTime)
8888

8989
assertFalse(first.collidesWith(second))
@@ -92,11 +92,11 @@ class WeekViewEventTest {
9292
@Test
9393
fun `overlapping events are recognized as colliding`() {
9494
val firstStartTime = now()
95-
val firstEndTime = firstStartTime + Hours(1)
95+
val firstEndTime = firstStartTime.plusHours(1)
9696
val first = Mocks.weekViewItem(firstStartTime, firstEndTime)
9797

98-
val secondStartTime = firstStartTime - Hours(1)
99-
val secondEndTime = firstEndTime + Hours(1)
98+
val secondStartTime = firstStartTime.minusHours(1)
99+
val secondEndTime = firstEndTime.plusHours(1)
100100
val second = Mocks.weekViewItem(secondStartTime, secondEndTime)
101101

102102
assertTrue(first.collidesWith(second))
@@ -105,11 +105,11 @@ class WeekViewEventTest {
105105
@Test
106106
fun `partly-overlapping events are recognized as colliding`() {
107107
val firstStartTime = now().withMinutes(0)
108-
val firstEndTime = firstStartTime + Hours(1)
108+
val firstEndTime = firstStartTime.plusHours(1)
109109
val first = Mocks.weekViewItem(firstStartTime, firstEndTime)
110110

111111
val secondStartTime = firstStartTime.withMinutes(30)
112-
val secondEndTime = secondStartTime + Hours(1)
112+
val secondEndTime = secondStartTime.plusHours(1)
113113
val second = Mocks.weekViewItem(secondStartTime, secondEndTime)
114114

115115
assertTrue(first.collidesWith(second))

0 commit comments

Comments
 (0)