Skip to content

Commit 068fdfb

Browse files
allowed using extended classes of WeekViewEvent in various functions
1 parent 610bd21 commit 068fdfb

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
google()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.2.0-alpha15'
10+
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

library/src/main/java/com/alamkanak/weekview/MonthLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MonthLoader(var onMonthChangeListener: MonthChangeListener?) : WeekViewLoa
88
return (instance.get(Calendar.YEAR) * 12).toDouble() + instance.get(Calendar.MONTH).toDouble() + (instance.get(Calendar.DAY_OF_MONTH) - 1) / 30.0
99
}
1010

11-
override fun onLoad(periodIndex: Int): MutableList<WeekViewEvent>? {
11+
override fun onLoad(periodIndex: Int): MutableList<out WeekViewEvent>? {
1212
return onMonthChangeListener!!.onMonthChange(periodIndex / 12, periodIndex % 12 + 1)
1313
}
1414

@@ -25,6 +25,6 @@ class MonthLoader(var onMonthChangeListener: MonthChangeListener?) : WeekViewLoa
2525
*month of the events required by the view **1 based (not like JAVA API) : January = 1 and December = 12**.
2626
* @return a list of the events happening **during the specified month**.
2727
*/
28-
fun onMonthChange(newYear: Int, newMonth: Int): MutableList<WeekViewEvent>?
28+
fun onMonthChange(newYear: Int, newMonth: Int): MutableList<out WeekViewEvent>?
2929
}
3030
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
222222
* your custom event loader by extending WeekViewLoader.
223223
*/
224224
val weekViewLoader: WeekViewLoader = PrefetchingWeekViewLoader(MonthLoader(object : MonthChangeListener {
225-
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<WeekViewEvent>? {
225+
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<out WeekViewEvent>? {
226226
return monthChangeListener?.onMonthChange(newYear, newMonth)
227227
}
228228
}))
@@ -1932,7 +1932,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
19321932
*
19331933
* @param events The events to be cached and sorted.
19341934
*/
1935-
private fun cacheAndSortEvents(events: MutableList<WeekViewEvent>?) {
1935+
private fun cacheAndSortEvents(events: MutableList<out WeekViewEvent>?) {
19361936
if (events != null)
19371937
for (event in events)
19381938
cacheEvent(event)

library/src/main/java/com/alamkanak/weekview/WeekViewLoader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ interface WeekViewLoader {
2222
* @param periodIndex the period to load
2323
* @return A list with the events of this period
2424
*/
25-
fun onLoad(periodIndex: Int): MutableList<WeekViewEvent>?
25+
fun onLoad(periodIndex: Int): MutableList<out WeekViewEvent>?
2626
}

sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ abstract class BaseActivity : AppCompatActivity(), WeekView.EventClickListener,
228228
Toast.makeText(this, "Empty view" + " clicked: " + getEventTitle(date), Toast.LENGTH_SHORT).show()
229229
}
230230

231-
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<WeekViewEvent>? {
231+
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<out WeekViewEvent>? {
232232
return null
233233
}
234234

sample/src/main/java/com/alamkanak/weekview/sample/BasicActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open class BasicActivity : BaseActivity() {
2020
weekView.typeface = ResourcesCompat.getFont(this, R.font.lato)
2121
}
2222

23-
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<WeekViewEvent>? {
23+
override fun onMonthChange(newYear: Int, newMonth: Int): MutableList<out WeekViewEvent>? {
2424
// Populate the week view with some events.
2525
val events = ArrayList<WeekViewEvent>()
2626

0 commit comments

Comments
 (0)