101Loop / DatePickerTimeline

Android Date Picker Library that provides a calendar as a horizontal timeline
Apache License 2.0
123 stars 37 forks source link

How to disable all the dates after a week from current date #10

Open ayushchaturvedi opened 4 years ago

ngacho commented 4 years ago

I think you can do the calculations yourself.

Here is how i would do it, Create a Calendar.getInstance() Object then using that calendar object, access its time, which will give current date Add seven days from to this current date and pass this as an array object into the deactivateDateMethod or you set it as the initial date. Users wont be able to access the other dates if it is the initial date anyways.

Taking the latter approach in Kotlin,

val cal = Calendar.getInstance() cal.add(cal[Calendar.DAY_OF_YEAR], 7) val dates = arrayOf(cal.time) datePickerTimeline.setInitialDate( cal[Calendar.YEAR], cal[Calendar.MONTH], cal[Calendar.DAY_OF_MONTH] )

Edited, added actual methods in kotlin