From 7a5a1d9c8957b830de75cad73949118747a070f7 Mon Sep 17 00:00:00 2001 From: dn Date: Tue, 4 Feb 2020 10:47:27 +0200 Subject: [PATCH] Add scroll to date method --- .../java/com/andrewjapar/rangedatepicker/CalendarPicker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rangedatepicker/src/main/java/com/andrewjapar/rangedatepicker/CalendarPicker.kt b/rangedatepicker/src/main/java/com/andrewjapar/rangedatepicker/CalendarPicker.kt index 6ecf5f9..6f31a1a 100644 --- a/rangedatepicker/src/main/java/com/andrewjapar/rangedatepicker/CalendarPicker.kt +++ b/rangedatepicker/src/main/java/com/andrewjapar/rangedatepicker/CalendarPicker.kt @@ -80,6 +80,13 @@ class CalendarPicker : RecyclerView { refreshData() } + fun scrollToDate(date: Date) { + val index = + mCalendarData.indexOfFirst { it is CalendarEntity.Day && it.date.isTheSameDay(date) } + require(index > -1) { "Date to scroll must be included in your Calendar Range Date" } + scrollToPosition(index) + } + fun showDayOfWeekTitle(show: Boolean) { mShowDayOfWeekTitle = show }