https://github.com/vrgsoftua/flexiblecalendarview
Calendar view
https://github.com/vrgsoftua/flexiblecalendarview
calendar calendar-view kotlin
Last synced: about 2 months ago
JSON representation
Calendar view
- Host: GitHub
- URL: https://github.com/vrgsoftua/flexiblecalendarview
- Owner: VRGsoftUA
- Created: 2018-01-10T15:17:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T09:01:32.000Z (almost 8 years ago)
- Last Synced: 2025-05-05T16:55:07.802Z (5 months ago)
- Topics: calendar, calendar-view, kotlin
- Language: Kotlin
- Homepage: http://vrgsoft.net/
- Size: 375 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FlexibleCalendarView
# Usage
*For a working implementation, Have a look at the Sample Project - sample*
1. Include the library as local library project.
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}dependencies {
implementation"com.github.VRGsoftUA:FlexibleCalendarView:1.0.1"
}
```
2. Include the FlexibleCalendarView widget in your layout.```xml
```
3. You can do same with kotlin
```kotlin
flexibleCalendarView.getSettings()
.setOnCalendarClickListener(this)
.setOnCalendarLongClickListener(this)
.setCalendarMonthCallback(this)
```
or```kotlin
vrCalendarView.getSettings()
.setOnCalendarClickListener(this)
.setOnCalendarLongClickListener(this)
.setVRCalendarMonthCallback(this);
```4. You can update all days by calling flexibleCalendarView.getSettings().updateCalendar();
```java
flexibleCalendarView.getSettings()
.setOtherMonthTextStyle(FlexibleCalendarView.BOLD)
.setCurrentMonthBackgroundColor(Color.CYAN)
.updateCalendar()
```
if FlexibleCalendarView.getSettings().updateCalendar() is called and you want to save some custom day
List getCustomizeDayView(Calendar calendar) method should be overridden
getCustomizeDayView(Calendar calendar) is return all days you need to make custom.
With parameter calendar you can get the year and the month to return customised days from specific month
```kotlin
override fun getCustomizeDayView(calendar: Calendar): List {return getCustomizeDayView(this)
}
fun getCustomizeDayView(context: Context): List {
val vrCalendarDays = ArrayList()vrCalendarDays.add(getSomeDay(context))
return vrCalendarDays
}
private fun getSomeDay(context: Context): CalendarDay {val someDay = CalendarDay()
val someDaySettings = CalendarDaySettings()
someDaySettings.dayTextColor = Color.CYAN
someDay.calendarDaySettings = someDaySettingsval cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -3)
someDay.date = cal.time
someDay.calendarDaySettings = someDaySettings
return someDay
}
```
You can set set whatever view you want and customise it like you want if standard customisation does not fit
Attention!!!
View getNewCustomiseView() should always return new View. other wise it doesn't work properly
```kotlin
someDay.customViewCallback = object : CustomCalendarDayCallback {
override fun getNewCustomiseView(): View {
val imageView = ImageView(context)
imageView.setImageResource(R.drawable.simple_ex)
return imageView
}
}
```but if you need to update specific day it is better to call
```kotlin
flexibleCalendarView.getSettings().updateCalendarDay(VrCalendarDay today, boolean hasToSelect);
```
where flexibleCalendarView has settings to customise specific day - hasToSelect should be false than
and hasToSelect is boolean that sets specific customisation
not from flexibleCalendarView settings but from default settings that has attribute "chosen". Like below
```xml
app:fcv_chosen_day_background_color="@color/colorGreen"
app:fcv_chosen_day_background_drawable="@drawable/background"
```
to update specific day you have to set VRCalendarDay.setDate(Date date); - it is required
```kotlin
val today = CalendarDay()
today.date = Date()
return today
```Move to date with
flexibleCalendarView.moveToDate(Date date);
5. There is onClick listener and onLongClick
```kotlin
interface OnCalendarLongClickListener {
fun onCalendarDayLongClick(day: CalendarDay)
}
```and
```kotlin
interface OnCalendarClickListener {
fun onCalendarDayClick(day: CalendarDay)
}that returns VrCalendarDay you click on
#### Customisation
You can add fields via xml or flexibleCalendarView or flexibleCalendarView.getSettings().
# Supported fields:| Method | Type |
| ------------- | ------------- |
| fcr_current_day_text_color | color |
| fcr_current_month_text_color | color |
| fcr_other_month_text_color | color |
| fcr_current_month_other_days_text_color | color |
| fcr_chosen_day_text_color |color |
| fcr_current_day_background_color | color |
| fcr_current_month_background_color | color |
| fcr_other_month_background_color | color |
| fcr_current_month_other_days_background_color |color |
| fcr_chosen_day_background_color | color |
| fcr_current_day_background_drawable | integer |
| fcr_current_month_background_drawable | integer |
| fcr_other_month_background_drawable" | integer |
| fcr_current_month_other_days_background_drawable | integer |
| fcr_chosen_day_background_drawable | integer |
| fcr_calendar_day_text_size | dimension |
| fcr_calendar_title_text_size | dimension |
| fcr_next_button | integer |
| fcr_previous_button | integer |
| fcr_title_text_color | color |
| fcr_background_color | color |
| fcr_week_days_color | color |
| fcr_current_day_text_style | normal,bold,italic |
| fcr_current_month_text_style | normal,bold,italic |
| fcr_other_month_text_style | normal,bold,italic |
| fcr_current_month_other_days_text_style | normal,bold,italic |
| fcr_chosen_day_text_style | normal,bold,italic |#### Contributing
* Contributions are always welcome
* If you want a feature and can code, feel free to fork and add the change yourself and make a pull request