AgendaCalendarView


Source link: https://github.com/Tibolte/AgendaCalendarView

AgendaCalendarView

This library replicates the basic features of the Calendar and Agenda views from the Sunrise Calendar (now Outlook) app, coupled with some small design touch from the Google Calendar app.

Usage

Grab it from maven:

 compile 'com.github.tibolte:agendacalendarview:1.0.4'

Declare this view in your layout like below, providing your own theme and colors if you want.

 <com.github.tibolte.agendacalendarview.AgendaCalendarView

android:id="@+id/agenda_calendar_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

agendaCalendar:agendaCurrentDayTextColor="@color/theme_primary"

agendaCalendar:calendarColor="@color/theme_primary"

agendaCalendar:calendarCurrentDayTextColor="@color/calendar_text_current_day"

agendaCalendar:calendarDayTextColor="@color/theme_text_icons"

agendaCalendar:calendarHeaderColor="@color/theme_primary_dark"

agendaCalendar:calendarPastDayTextColor="@color/theme_light_primary"

agendaCalendar:fabColor="@color/theme_accent" />

Then configure it in your code with a start and end date associated with a list of events:


  // minimum and maximum date of our calendar

// 2 month behind, one year ahead, example: March 2015 <-> May 2015 <-> May 2016

Calendar minDate = Calendar.getInstance();

Calendar maxDate = Calendar.getInstance();

 minDate.add(Calendar.MONTH, -2);

minDate.set(Calendar.DAY_OF_MONTH, 1);

maxDate.add(Calendar.YEAR, 1);

 List<CalendarEvent> eventList = new ArrayList<>();

mockList(eventList);

 mAgendaCalendarView.init(eventList, minDate, maxDate, Locale.getDefault(), this);

The event list contains BaseCalendarEvent instances, see the description of the parameters:

 /** 
  * Initializes the event 
  * 
  * @param id

 The id of the event. 
  * @param color

 The color of the event. 
  * @param title

 The title of the event. 
  * @param description The description of the event. 
  * @param location
 The location of the event. 
  * @param dateStart
The start date of the event. 
  * @param dateEnd
  The end date of the event. 
  * @param allDay

Int that can be equal to 0 or 1. 
  * @param duration
 The duration of the event in RFC2445 format. 
  */
  public BaseCalendarEvent(long id, int color, String title, String description, String location, long dateStart, long dateEnd, int allDay, String duration) {

this.mId = id;

this.mColor = color;

this.mAllDay = (allDay == 1) ? true : false;

this.mDuration = duration;

this.mTitle = title;

this.mDescription = description;

this.mLocation = location;

 this.mStartTime = Calendar.getInstance();

this.mStartTime.setTimeInMillis(dateStart);

this.mEndTime = Calendar.getInstance();

this.mEndTime.setTimeInMillis(dateEnd);

  
}

Here is a quick (and very simple) example providing a list of events, you can provide several layouts too:

 private void mockList(List<CalendarEvent> eventList) {

Calendar startTime1 = Calendar.getInstance();

Calendar endTime1 = Calendar.getInstance();

endTime1.add(Calendar.MONTH, 1);

BaseCalendarEvent event1 = new BaseCalendarEvent("Thibault travels in Iceland", "A wonderful journey!", "Iceland",

  ContextCompat.getColor(this, R.color.orange_dark), startTime1, endTime1, true);

eventList.add(event1);

 Calendar startTime2 = Calendar.getInstance();

startTime2.add(Calendar.DAY_OF_YEAR, 1);

Calendar endTime2 = Calendar.getInstance();

endTime2.add(Calendar.DAY_OF_YEAR, 3);

BaseCalendarEvent event2 = new BaseCalendarEvent("Visit to Dalvík", "A beautiful small town", "Dalvík",

  ContextCompat.getColor(this, R.color.yellow), startTime2, endTime2, true);

eventList.add(event2);

 // Example on how to provide your own layout

Calendar startTime3 = Calendar.getInstance();

Calendar endTime3 = Calendar.getInstance();

startTime3.set(Calendar.HOUR_OF_DAY, 14);

startTime3.set(Calendar.MINUTE, 0);

endTime3.set(Calendar.HOUR_OF_DAY, 15);

endTime3.set(Calendar.MINUTE, 0);

DrawableCalendarEvent event3 = new DrawableCalendarEvent("Visit of Harpa", "", "Dalvík",

  ContextCompat.getColor(this, R.color.blue_dark), startTime3, endTime3, false, R.drawable.common_ic_googleplayservices);

eventList.add(event3);

  
}

Roadmap (feel free to suggest any other improvement ideas)

. Parallax items like in Google Calendar
. Easier way to provide your own list of events (i.e when receiving objects from a web API)

Participating?

Make your pull requests on feature or bugfix branches.

Special thanks to these contributors

FHellmann

License

Copyright 2015 Thibault Guégan  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

BusWear is a simple library for EventBus to support Android Wear devices. Just adding one line of code lets you get synchronized event buses on Wear and mobile platform.

Qachee is a generic cache system to use specially for Android Apps. It is just a LRU Memory cache with policy expiration and lots of useful methods.

RefreshMenuItem is a Menu item that shows an indeterminate progress in the Android ActionBar. It is simple to use, lightweight, scalable and uses intuitive methods names.

What is Android Promise

A library for modular asynchronous calls.

Boogaloo is a task-retry manager with a certain back-off time.

A View holder generator for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes