• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

JonasWanke/com.jonaswanke.calendar:

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

JonasWanke/com.jonaswanke.calendar

开源软件地址(OpenSource Url):

https://github.com/JonasWanke/com.jonaswanke.calendar

开源编程语言(OpenSource Language):

Kotlin 98.3%

开源软件介绍(OpenSource Introduction):

No longer supported

Unfortunately, I no longer have the time to continue developing this library and my focus has shifted. If you are switching to Flutter, you might be interested in my timetable package as a replacement.

CalendarView

Build Status Bintray

Apache 2.0 license Semver Awesome Badges

This library provides a Material Design CalendarView for Android (week and day view; more coming soon!). The default style is copied from the Google Calendar app, but almost everything is customizable.

Screenshot of the example app Day view Add event by tapping empty space
image image image

Features

  • Week and Day views
  • Scroll and zoom
  • All-day events (and events > 24h) shown at the top
  • All colors and most spacings are customizable

Usage

  1. Add the library to your gradle script
implementation 'com.jonaswanke.calendar:calendar:0.1.1'
  1. Add CalendarView in you layout
<com.jonaswanke.calendar.CalendarView
    android:id="@+id/calendar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:range="week" />

Currently supported ranges are week and day. More coming soon!

  1. Provide events to the view
calendar.eventRequestCallback = { week ->
    // Retrieve events synchronously or asynchronously
    val events: List<Event> = // ...
    calendar.setEventsForWeek(week, events)
}

CalendarView currently caches two views for either side of the current view (e.g. two weeks to the left and two to the right) for smooth swiping. When a new view is loaded, eventRequestCallback will be called with the new week.
You should then supply events starting in that week by calling calendar.setEventsForWeek() (multi-day and multi-week events are always stored where they begin and will then be distributed to where they are required).

You can call calendar.setEventsForWeek() anytime you want. The events will be cached and used when required. Old events starting in that week are overridden.

Events implement the following properties:

val title: String // Displayed in bold
val description: String? // Optional; shown in a second line
@get:ColorInt
val color: Int? // Optional background color
val start: Long // Start time
val end: Long // End time
val allDay: Boolean // Whether the event takes all day. If so, start and end are just used to determine the day
  1. Add your listeners (optional)
calendar.onEventClickListener = { event ->
    // Event was clicked
    Toast.makeText(this, "${event.title} clicked", Toast.LENGTH_LONG).show()
}
calendar.onEventLongClickListener = { event ->
    // Event was long clicked
    Toast.makeText(this, "${event.title} long clicked", Toast.LENGTH_LONG).show()
}

As shown in screenshot 3 (above), the user can add events by tapping empty space inside CalendarView. This only works when an onAddEventListener is set.

calendar.onAddEventListener = { addEvent ->
    // User tried to create a new event. addEvent is an event with populated start and end.
    Toast.makeText(this, "Add event at ${start}", Toast.LENGTH_SHORT).show()
    // Return true to remove the placeholder
    true
}

Sample

There is also a sample app to get you started.

Customization

Following soon...

Changelog

See here for the changelog.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap