{"id":3476,"url":"https://github.com/CleverPumpkin/CrunchyCalendar","last_synced_at":"2025-08-03T19:31:34.606Z","repository":{"id":53150530,"uuid":"134849459","full_name":"CleverPumpkin/CrunchyCalendar","owner":"CleverPumpkin","description":"A beautiful material calendar with endless scroll, range selection and a lot more!","archived":false,"fork":false,"pushed_at":"2024-02-05T13:23:30.000Z","size":4951,"stargazers_count":647,"open_issues_count":14,"forks_count":46,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-08-16T14:34:32.235Z","etag":null,"topics":["android","calendar","calendar-view","custom-view","java","jcenter","kotlin","material-calendar","material-design","range-selection"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CleverPumpkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-05-25T11:51:19.000Z","updated_at":"2024-08-09T20:14:02.000Z","dependencies_parsed_at":"2024-02-05T13:29:54.271Z","dependency_job_id":"e14270fd-f301-4547-9f3c-cbd18071d4c5","html_url":"https://github.com/CleverPumpkin/CrunchyCalendar","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverPumpkin%2FCrunchyCalendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverPumpkin%2FCrunchyCalendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverPumpkin%2FCrunchyCalendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleverPumpkin%2FCrunchyCalendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CleverPumpkin","download_url":"https://codeload.github.com/CleverPumpkin/CrunchyCalendar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228561530,"owners_count":17937171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","calendar","calendar-view","custom-view","java","jcenter","kotlin","material-calendar","material-design","range-selection"],"created_at":"2024-01-05T20:16:42.594Z","updated_at":"2024-12-07T04:31:29.201Z","avatar_url":"https://github.com/CleverPumpkin.png","language":"Kotlin","funding_links":[],"categories":["Useful links","Libraries"],"sub_categories":["Sample apps and libraries","GUI"],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ru.cleverpumpkin/crunchycalendar/badge.svg)](https://maven-badges.herokuapp.com/maven-central/ru.cleverpumpkin/crunchycalendar/)\n\n![alt text](images/Cover.png)\n\n# CrunchyCalendar\n\nA **light**, **powerful** and **easy to use** Calendar Widget with a number out of the box features:\n* Infinite vertical scrolling in both directions;\n* Setting date boundaries to restrict scrolling inside of a specific time period;\n* Single / multiple / range dates selection;\n* Pre-selecting dates;\n* Color customization;\n* Displaying color indicators;\n* Setting own custom ItemDecoration;\n* Presented as a View subclass which can be displayed everywhere: in Activity, Fragment or Dialog, \nor can be integrated into another custom View.\n\n![alt text](images/calendar.jpg)\n\n## Dependency\n\nThis library is available on [Maven Central](https://search.maven.org/artifact/ru.cleverpumpkin/crunchycalendar) (Previously on [jCenter](https://bintray.com/cleverpumpkin/maven/CrunchyCalendar)).\n\n#### Gradle\n\n```\nimplementation 'ru.cleverpumpkin:crunchycalendar:2.6.1'\n```\n\n#### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eru.cleverpumpkin\u003c/groupId\u003e\n  \u003cartifactId\u003ecrunchycalendar\u003c/artifactId\u003e\n  \u003cversion\u003e2.6.1\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\nHere's a basic example of Calendar usage.\n \nFirst of all, you should declare `CalendarView` in your layout XML file.\n\n```xml\n  \u003cru.cleverpumpkin.calendar.CalendarView \n        android:id=\"@+id/calendar_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\" /\u003e\n```\n\nPerform Calendar setup in your `Activity` or `Fragment` class.\n\n```kotlin\n\nval calendarView = view.findViewById(R.id.calendar_view)\nval calendar = Calendar.getInstance()\n\n// Initial date\ncalendar.set(2018, Calendar.JUNE, 1)\nval initialDate = CalendarDate(calendar.time)\n\n// Minimum available date\ncalendar.set(2018, Calendar.MAY, 15)\nval minDate = CalendarDate(calendar.time)\n\n// Maximum available date\ncalendar.set(2018, Calendar.JULY, 15)\nval maxDate = CalendarDate(calendar.time)\n\n// List of preselected dates that will be initially selected\nval preselectedDates: List\u003cCalendarDate\u003e = getPreselectedDates()\n\n// The first day of week\nval firstDayOfWeek = java.util.Calendar.MONDAY\n\n// Set up calendar with all available parameters\ncalendarView.setupCalendar(\n    initialDate = initialDate, \n    minDate = minDate,\n    maxDate = maxDate,\n    selectionMode = SelectionMode.NONE,\n    selectedDates = preselectedDates,\n    firstDayOfWeek = firstDayOfWeek,\n    showYearSelectionView = true\n)\n                \n```\n\n**Note:** all parameters in `setupCalendar()` method are optional and have default values. \n\nTo handle date click / long click with custom action, you can do this:\n\n```kotlin\n\n// Set date click callback \ncalendarView.onDateClickListener = { date -\u003e\n\n    // Do something ... \n    // for example get list of selected dates\n    val selectedDates = calendarView.selectedDates \n}\n\n// Set date long click callback \ncalendarView.onDateLongClickListener = { date -\u003e\n\n    // Do something ... \n}\n\n```\n\n\n## Saving and Restoring state  \nCalendar takes care of saving and restoring its internal state (selected dates, selection mode, etc.),\nso there's no need to save it manually and call `CalendarView.setupCalendar()` method every time, \nwhen `Activity` or `Fragment` is recreated.\n\nIf a Calendar was set up with `CalendarView.setupCalendar()` method **before** restoring state, previous saved \nstate will be ignored. \n\n## Dates Selection\nCalendar supports several selection modes: **single**, **multiple** and **range**.\n\n**Note:** You can restrict selection of some dates by implementing your own filtration logic:\n\n```kotlin\n\n// Here we make weekends unavailable for selection\ncalendarView.dateSelectionFilter = { date -\u003e\n    date.dayOfWeek != Calendar.SATURDAY \u0026\u0026 date.dayOfWeek != Calendar.SUNDAY\n}\n```\n\n#### Single date selection \nOnly one date can be selected at a time.\n\n```kotlin\n\n// Set up calendar with SelectionMode.SINGLE\ncalendarView.setupCalendar(selectionMode = SelectionMode.SINGLE)\n\n...\n\n// Get selected date or null\nval selectedDate: CalendarDate? = calendarView.selectedDate\n\n// Get list with single selected date or empty list\nval selectedDates: List\u003cCalendarDate\u003e = calendarView.selectedDates\n```\n\n#### Multiple dates selection \nA number of dates can be selected. Pressing an already selected date will unselect it.\n\n```kotlin\n\n// Set up calendar with SelectionMode.MULTIPLE\ncalendarView.setupCalendar(selectionMode = SelectionMode.MULTIPLE)\n\n...\n\n// Get all selected dates in order they were added or empty list\nval selectedDates: List\u003cCalendarDate\u003e = calendarView.selectedDates\n\n```\n\n#### Range date selection \nAllows you to select a date range. Previous selected range is cleared when you select another one.\n\n```kotlin\n\n// Set up calendar with SelectionMode.RANGE\ncalendarView.setupCalendar(selectionMode = SelectionMode.RANGE)\n\n... \n\n// Get all selected dates in range (includes start and end date) or empty list\nval selectedDates: List\u003cCalendarDate\u003e = calendarView.selectedDates\n\n```\n\n## Color Indicators\nThe Calendar is able to display simple color indicators (dots) on the date cell.\n\nColor indicator represents as simple interface, which you can implement in your classes.  \n\n```kotlin\n\ninterface DateIndicator {\n    val date: CalendarDate // indicator date\n    val color: Int // indicator color\n}\n\n```\n\nHere's an example of setting indicators to display on the Calendar.\n \n```kotlin\n\n// Set up calendar\ncalendarView.setupCalendar()\n\n\nval indicators: List\u003cDateIndicator\u003e = getDatesIndicators()\n\n// Set List of indicators that will be displayed on the calendar \ncalendarView.datesIndicators = indicators\n\n\n````\n\nTo get all indicators for specific date, you can do this:\n\n```kotlin\n\n// Set date click callback \ncalendarView.onDateClickListener = { date -\u003e\n\n    // Get all indicators for the date\n    val indicatorsForDate = calendarView.getDateIndicators(date)\n    \n    // do something ... \n}\n\n```\n\n## Additional text on date cell\nThe Calendar is able to display additional text on the date cell.\n\nAdditional text represents as simple interface, which you can implement in your classes.\n\n```kotlin\n\ninterface AdditionalText {\n    val date: CalendarDate // text's date\n    val text: String // text to display\n    val color: Int // text's color\n}\n\n```\n\nHere's an example of setting additional text to display on the Calendar.\n\n```kotlin\n\n// Set up calendar\ncalendarView.setupCalendar()\n\n\nval additionalTexts: List\u003cAdditionalText\u003e = generateAdditionalTexts()\n\n// Set List of additional texts that will be displayed on the calendar \ncalendarView.datesAdditionalTexts = additionalTexts\n\n\n````\n\n## Using default or root locale on digits\nThe Calendar is able to display digits using default or root locale.\n\n```kotlin\n\n// Set true for root locale or false for default locale. If nothing is set default locale will be used.\nsetUseRootLocale(true)\n\n// Then set up calendar\ncalendarView.setupCalendar()\n\n````\n\n## View Customization\nCalendar appearance open for customization.\n\n#### Styling using XML\n\nCalendar appearance can be customized with XML attributes. Here's an example of applying custom style to change Calendar appearance.\n\nDefine your custom style for the Calendar.\n```xml\n\u003cstyle name=\"CalendarViewCustomStyle\"\u003e\n    \u003citem name=\"android:background\"\u003e@android:color/white\u003c/item\u003e\n    \u003citem name=\"calendar_date_background\"\u003e@drawable/custom_date_bg_selector\u003c/item\u003e\n    \u003citem name=\"calendar_date_text_color\"\u003e@color/custom_date_text_selector\u003c/item\u003e\n    \u003citem name=\"calendar_day_bar_background\"\u003e@color/custom_calendar_days_bar_background\u003c/item\u003e\n    \u003citem name=\"calendar_day_bar_text_color\"\u003e@color/custom_calendar_days_bar_text_color\u003c/item\u003e\n    \u003citem name=\"calendar_day_bar_weekend_text_color\"\u003e@color/custom_calendar_days_bar_text_color\u003c/item\u003e\n    \u003citem name=\"calendar_grid_color\"\u003e@color/custom_calendar_grid_color\u003c/item\u003e\n    \u003citem name=\"calendar_grid_on_selected_dates\"\u003efalse\u003c/item\u003e\n    \u003citem name=\"calendar_month_text_color\"\u003e@color/custom_calendar_month_text_color\u003c/item\u003e\n    \u003citem name=\"calendar_year_selection_arrows_color\"\u003e\n        @color/custom_calendar_year_selection_arrows_color\n    \u003c/item\u003e\n    \u003citem name=\"calendar_year_selection_background\"\u003e\n        @color/custom_calendar_year_selection_background\n    \u003c/item\u003e\n    \u003citem name=\"calendar_year_selection_text_color\"\u003e\n        @color/custom_calendar_year_selection_text_color\n    \u003c/item\u003e\n\u003c/style\u003e\n```\n\nApply your custom style.\n```xml\n\n\u003cru.cleverpumpkin.calendar.CalendarView\n    android:id=\"@+id/calendar_view\"\n    style=\"@style/CalendarViewCustomStyle\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" /\u003e\n\n```\n\nTo define custom styles for all Calendars in your app at once you can do this:\n```xml\n\n\u003cstyle name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\"\u003e\n\n    \u003c!-- ...snip... --\u003e\n    \n    \u003citem name=\"calendarViewStyle\"\u003e@style/CalendarViewCustomStyle\u003c/item\u003e\n    \n    \u003c!-- ...etc... --\u003e\n\u003c/style\u003e\n```\n\n#### Styling using code\nYou can also set styles and colors programmatically:\n\n```kotlin\n with(calendarView) {\n     setDrawGridOnSelectedDates(drawGrid = true)\n     setGridColorRes(R.color.custom_calendar_grid_color)\n     setYearSelectionBarBackgroundColorRes(R.color.custom_calendar_year_selection_background)\n     setYearSelectionBarArrowsColorRes(R.color.custom_calendar_year_selection_arrows_color)\n     setYearSelectionBarTextColorRes(R.color.custom_calendar_year_selection_text_color)\n     setDaysBarBackgroundColorRes(R.color.custom_calendar_days_bar_background)\n     setDaysBarTextColorRes(R.color.custom_calendar_days_bar_text_color)\n     setDaysBarWeekendTextColorRes(R.color.custom_calendar_days_bar_text_color)\n     setMonthTextColorRes(R.color.custom_calendar_month_text_color)\n     setDateCellBackgroundRes(R.drawable.custom_date_bg_selector)\n     setDateCellTextColorRes(R.color.custom_date_text_selector)\n}\n```\n\nIf you need to add some custom drawing logic for Calendar, you can implement standard \n`RecyclerView.ItemDecoration` and add it for Calendar using `addCustomItemDecoration()` method.\n\n```kotlin\n// Set up calendar\ncalendarView.setupCalendar()\n\n// Some custom decoration logic \nval customItemDecoration = CustomItemDecoration()\n\n// Add custom item decoration for calendar\ncalendarView.addCustomItemDecoration(customItemDecoration)\n\n```    \n\nThere is an abstract helper class `AbsDateItemDecoration` that you can extend to implement custom \ndrawing logic for specific dates cells.\n\n## Sample app\nThe Sample app is available for download from [Google Play](https://play.google.com/store/apps/details?id=ru.cleverpumpkin.calendar.sample).\n\n## Sketch file\n\nWouldn’t it be a real pain for your designer to ignore Calendar View in your apps mockups? Or for them to try and explain to you, which colors you should use by adding them to Jira task in _plain text_?\n\nThat is lame. That’s why we’ve added a `.sketch`-file to this repository [here](Calendar%20for%20Android.sketch). Have fun!\n\n## License\n\n```\n\nMIT License\n\nCopyright (c) 2018 CleverPumpkin Ltd.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```\n\n## Maintainers\n\n![alt text](images/cleverpumpkin.png)\n\nCrunchyCalendar is maintained and developed by [CleverPumpkin](https://cleverpumpkin.ru).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCleverPumpkin%2FCrunchyCalendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCleverPumpkin%2FCrunchyCalendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCleverPumpkin%2FCrunchyCalendar/lists"}