Skip to content

Commit 4752965

Browse files
committed
Upgrade deprecation level for some deprecated properties
1 parent ed40e12 commit 4752965

7 files changed

Lines changed: 57 additions & 37 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ internal class ViewState {
2323

2424
// Calendar state
2525
var firstVisibleDate: Calendar = today()
26-
var scrollToDate: Calendar? = null
27-
var scrollToHour: Int? = null
26+
var pendingScroll: Calendar? = null
2827

2928
private var isFirstDraw: Boolean = true
3029

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

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,17 @@ class WeekView @JvmOverloads constructor(
100100

101101
override fun onDraw(canvas: Canvas) {
102102
super.onDraw(canvas)
103-
performPendingScrolls()
103+
performPendingScroll()
104104
updateViewState()
105105
refreshEvents()
106106
performRendering(canvas)
107107
}
108108

109-
private fun performPendingScrolls() {
110-
val pendingDateScroll = viewState.scrollToDate
111-
viewState.scrollToDate = null
112-
pendingDateScroll?.let { date ->
113-
goToDate(date)
114-
}
115-
116-
val pendingHourScroll = viewState.scrollToHour
117-
viewState.scrollToHour = null
118-
pendingHourScroll?.let { hour ->
119-
goToHour(hour)
109+
private fun performPendingScroll() {
110+
val pendingScroll = viewState.pendingScroll
111+
viewState.pendingScroll = null
112+
pendingScroll?.let { dateTime ->
113+
scrollToDateTime(dateTime)
120114
}
121115
}
122116

@@ -154,7 +148,7 @@ class WeekView @JvmOverloads constructor(
154148
viewState.numberOfVisibleDays = savedState.numberOfVisibleDays
155149
}
156150

157-
goToDate(savedState.firstVisibleDate)
151+
scrollToDate(savedState.firstVisibleDate)
158152
}
159153

160154
override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
@@ -212,7 +206,6 @@ class WeekView @JvmOverloads constructor(
212206
val currentFirstVisibleDate = viewState.firstVisibleDate
213207
viewState.numberOfVisibleDays = value
214208

215-
dateTimeInterpreter.onSetNumberOfDays(value)
216209
renderers.filterIsInstance(DateFormatterDependent::class.java).forEach {
217210
it.onDateFormatterChanged(viewState.dateFormatter)
218211
}
@@ -1107,7 +1100,10 @@ class WeekView @JvmOverloads constructor(
11071100
* Returns the scrolling speed factor in horizontal direction.
11081101
*/
11091102
@PublicApi
1110-
@Deprecated("This value is no longer being taken into account.")
1103+
@Deprecated(
1104+
message = "This value is no longer being taken into account.",
1105+
level = DeprecationLevel.ERROR
1106+
)
11111107
var xScrollingSpeed: Float
11121108
get() = viewState.xScrollingSpeed
11131109
set(value) {
@@ -1120,7 +1116,8 @@ class WeekView @JvmOverloads constructor(
11201116
@PublicApi
11211117
@Deprecated(
11221118
message = "Use isHorizontalScrollingEnabled instead.",
1123-
replaceWith = ReplaceWith("isHorizontalScrollingEnabled")
1119+
replaceWith = ReplaceWith("isHorizontalScrollingEnabled"),
1120+
level = DeprecationLevel.ERROR
11241121
)
11251122
var isHorizontalFlingEnabled: Boolean
11261123
get() = viewState.horizontalFlingEnabled
@@ -1141,7 +1138,10 @@ class WeekView @JvmOverloads constructor(
11411138
/**
11421139
* Returns whether WeekView can fling vertically.
11431140
*/
1144-
@Deprecated("This value is no longer being taken into account.")
1141+
@Deprecated(
1142+
message = "This value is no longer being taken into account.",
1143+
level = DeprecationLevel.ERROR
1144+
)
11451145
@PublicApi
11461146
var isVerticalFlingEnabled: Boolean
11471147
get() = viewState.verticalFlingEnabled
@@ -1150,7 +1150,10 @@ class WeekView @JvmOverloads constructor(
11501150
}
11511151

11521152
@PublicApi
1153-
@Deprecated("This value is no longer being taken into account.")
1153+
@Deprecated(
1154+
message = "This value is no longer being taken into account.",
1155+
level = DeprecationLevel.ERROR
1156+
)
11541157
var scrollDuration: Int
11551158
get() = viewState.scrollDuration
11561159
set(value) {
@@ -1220,7 +1223,7 @@ class WeekView @JvmOverloads constructor(
12201223
if (isWaitingToBeLaidOut) {
12211224
// If the view's dimensions have just changed or if it hasn't been laid out yet, we
12221225
// postpone the action until onDraw() is called the next time.
1223-
viewState.scrollToHour = hour
1226+
viewState.pendingScroll = viewState.firstVisibleDate.withTime(hour, minute)
12241227
return
12251228
}
12261229

@@ -1251,7 +1254,8 @@ class WeekView @JvmOverloads constructor(
12511254
*/
12521255
@Deprecated(
12531256
message = "This method will be removed in a future release. Use scrollToDate() instead.",
1254-
replaceWith = ReplaceWith(expression = "scrollToDate")
1257+
replaceWith = ReplaceWith(expression = "scrollToDate"),
1258+
level = DeprecationLevel.ERROR
12551259
)
12561260
@PublicApi
12571261
fun goToToday() {
@@ -1263,7 +1267,8 @@ class WeekView @JvmOverloads constructor(
12631267
*/
12641268
@Deprecated(
12651269
message = "This method will be removed in a future release. Use scrollToDateTime() instead.",
1266-
replaceWith = ReplaceWith(expression = "scrollToDateTime")
1270+
replaceWith = ReplaceWith(expression = "scrollToDateTime"),
1271+
level = DeprecationLevel.ERROR
12671272
)
12681273
@PublicApi
12691274
fun goToCurrentTime() {
@@ -1281,7 +1286,8 @@ class WeekView @JvmOverloads constructor(
12811286
*/
12821287
@Deprecated(
12831288
message = "This method will be removed in a future release. Use scrollToDate() instead.",
1284-
replaceWith = ReplaceWith(expression = "scrollToDate")
1289+
replaceWith = ReplaceWith(expression = "scrollToDate"),
1290+
level = DeprecationLevel.ERROR
12851291
)
12861292
@PublicApi
12871293
fun goToDate(date: Calendar) {
@@ -1300,7 +1306,7 @@ class WeekView @JvmOverloads constructor(
13001306
if (isWaitingToBeLaidOut) {
13011307
// If the view's dimensions have just changed or if it hasn't been laid out yet, we
13021308
// postpone the action until onDraw() is called the next time.
1303-
viewState.scrollToDate = adjustedDate
1309+
viewState.pendingScroll = adjustedDate
13041310
return
13051311
}
13061312

@@ -1315,7 +1321,8 @@ class WeekView @JvmOverloads constructor(
13151321
*/
13161322
@Deprecated(
13171323
message = "This method will be removed in a future release. Use scrollToTime() instead.",
1318-
replaceWith = ReplaceWith(expression = "scrollToTime")
1324+
replaceWith = ReplaceWith(expression = "scrollToTime"),
1325+
level = DeprecationLevel.ERROR
13191326
)
13201327
@PublicApi
13211328
fun goToHour(hour: Int) {
@@ -1379,7 +1386,10 @@ class WeekView @JvmOverloads constructor(
13791386
}
13801387

13811388
@PublicApi
1382-
@Deprecated("Use setDateFormatter() and setTimeFormatter() instead.")
1389+
@Deprecated(
1390+
message = "Use setDateFormatter() and setTimeFormatter() instead.",
1391+
level = DeprecationLevel.ERROR
1392+
)
13831393
var dateTimeInterpreter: DateTimeInterpreter
13841394
get() = object : DateTimeInterpreter {
13851395
override fun interpretDate(date: Calendar): String = viewState.dateFormatter(date)
@@ -1599,7 +1609,8 @@ class WeekView @JvmOverloads constructor(
15991609
@PublicApi
16001610
@Deprecated(
16011611
message = "Use submitList() to submit a list of elements of type T instead. Then, overwrite the adapter's onCreateEntity() method to create a WeekViewEntity.",
1602-
replaceWith = ReplaceWith(expression = "submitList")
1612+
replaceWith = ReplaceWith(expression = "submitList"),
1613+
level = DeprecationLevel.ERROR
16031614
)
16041615
fun submit(events: List<WeekViewDisplayable<T>>) {
16051616
val viewState = weekView?.viewState ?: return
@@ -1649,7 +1660,8 @@ class WeekView @JvmOverloads constructor(
16491660
@PublicApi
16501661
@Deprecated(
16511662
message = "Use submitList() to submit a list of elements of type T instead. Then, overwrite the adapter's onCreateEntity() method to create a WeekViewEntity.",
1652-
replaceWith = ReplaceWith(expression = "submitList")
1663+
replaceWith = ReplaceWith(expression = "submitList"),
1664+
level = DeprecationLevel.ERROR
16531665
)
16541666
fun submit(events: List<WeekViewDisplayable<T>>) {
16551667
val viewState = weekView?.viewState ?: return

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ sealed class WeekViewEntity {
6666

6767
@Deprecated(
6868
message = "Use setSubtitle() instead.",
69-
replaceWith = ReplaceWith(expression = "setSubtitle")
69+
replaceWith = ReplaceWith(expression = "setSubtitle"),
70+
level = DeprecationLevel.ERROR
7071
)
7172
@PublicApi
7273
fun setLocation(location: CharSequence): Builder<T> {
@@ -76,7 +77,8 @@ sealed class WeekViewEntity {
7677

7778
@Deprecated(
7879
message = "Use setSubtitle() instead.",
79-
replaceWith = ReplaceWith(expression = "setSubtitle")
80+
replaceWith = ReplaceWith(expression = "setSubtitle"),
81+
level = DeprecationLevel.ERROR
8082
)
8183
@PublicApi
8284
fun setLocation(resId: Int): Builder<T> {
@@ -251,7 +253,10 @@ sealed class WeekViewEntity {
251253
}
252254

253255
@PublicApi
254-
@Deprecated("Use a SpannableString for the title or location instead.")
256+
@Deprecated(
257+
message = "Use a SpannableString for the title and subtitle instead.",
258+
level = DeprecationLevel.ERROR
259+
)
255260
fun setTextStrikeThrough(strikeThrough: Boolean): Builder {
256261
style.isTextStrikeThrough = strikeThrough
257262
return this
@@ -377,7 +382,7 @@ data class WeekViewEvent<T> internal constructor(
377382
}
378383

379384
@PublicApi
380-
@Deprecated("Use a SpannableString for the title or location instead.")
385+
@Deprecated("Use a SpannableString for the title or subtitle instead.")
381386
fun setTextStrikeThrough(strikeThrough: Boolean): Builder {
382387
style.isTextStrikeThrough = strikeThrough
383388
return this

emoji/src/main/java/com/alamkanak/weekview/emoji/EmojiProcessingInitializer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class EmojiProcessingInitializer : Initializer<Unit> {
2424
* Enables emoji processing for entity titles and subtitles in WeekView.
2525
*/
2626
@Deprecated(
27-
message = "Emoji processing is now done automatically. Calling this method is not necessary anymore."
27+
message = "Emoji processing is now done automatically. Calling this method is not necessary anymore.",
28+
level = DeprecationLevel.ERROR
2829
)
2930
fun WeekView.enableEmojiProcessing() {
3031
// Nothing to do here

jodatime/src/main/java/com/alamkanak/weekview/jodatime/WeekViewExtensions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ val WeekView.lastVisibleDateAsLocalDate: LocalDate
7171
*/
7272
@Deprecated(
7373
message = "This method has been renamed to scrollTo().",
74-
replaceWith = ReplaceWith(expression = "scrollTo")
74+
replaceWith = ReplaceWith(expression = "scrollTo"),
75+
level = DeprecationLevel.ERROR
7576
)
7677
fun WeekView.goToDate(date: LocalDate) {
7778
scrollToDate(date)

jsr310/src/main/java/com/alamkanak/weekview/jsr310/WeekViewExtensions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ val WeekView.lastVisibleDateAsLocalDate: LocalDate
7171
*/
7272
@Deprecated(
7373
message = "This method has been renamed to scrollTo().",
74-
replaceWith = ReplaceWith(expression = "scrollTo")
74+
replaceWith = ReplaceWith(expression = "scrollTo"),
75+
level = DeprecationLevel.ERROR
7576
)
7677
fun WeekView.goToDate(date: LocalDate) {
7778
scrollToDate(date)

threetenabp/src/main/java/com/alamkanak/weekview/threetenabp/WeekViewExtensions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ val WeekView.lastVisibleDateAsLocalDate: LocalDate
7171
*/
7272
@Deprecated(
7373
message = "This method has been renamed to scrollToDate(LocalDate).",
74-
replaceWith = ReplaceWith(expression = "scrollToDate")
74+
replaceWith = ReplaceWith(expression = "scrollToDate"),
75+
level = DeprecationLevel.ERROR
7576
)
7677
fun WeekView.goToDate(date: LocalDate) {
7778
scrollToDate(date)

0 commit comments

Comments
 (0)