Material-calendarview: adding events and showing events

Created on 19 Feb 2015  Â·  22Comments  Â·  Source: prolificinteractive/material-calendarview

adding events and showing events in the calender like calendar app in android.

enhancement

Most helpful comment

A more general solution would be to provide custom decorators to day views. I was working on a very simple implementation that allows you to do so https://github.com/angelpinheiro/material-calendarview/commit/7d7f1ce132544850366d71314dd29ce3d3e0f1ac. I have also updated the sample project with a new example that looks like this:

First you define your decorator, to decorate day views as you want:

public class HighlightDecorator implements DayViewDecorator{
    @Override
    public void decorate(DayView view,Context context) {
        view.setBackground(generateCircleDrawable(color));
    }
}

Then you tell calendar widget wich dates you want to decorate:

widget.addDayViewDecorator(new HighlightDecorator(), dates)
widget.addDayViewDecorator(new AnotherDecorator(), ...)

You can probably improve it in many ways, since I do not know very well the architecture of the library, but it's a starting point. I will do a pull request if you are interested!

All 22 comments

I'm not sure where this fits into the goal of the project, which is to make a date picker widget of material design. I'm not against it, but this will likely take low priority, unless this is a popular request.

While this percolates:

What kind of API are you thinking of? Something like this:

calendarView.addEvent(new Event(date, "Extra Data"));

And how should events be shown indicated on the view?

Maybe just some different highlighting for a few "event" dates in the background using would be the easiest without a whole different UI. Might be nice option to highlight today's date too?

@dandc87

Thanks for the comments.

Exactly like this.
calendarView.addEvent(new Event(date, "Extra Data"));

I support this idea, i'll try to see if I can help

So, when will be update? I can't wait. I haven't seen usage like this in other libraries, so i hope update will be soon

I would be happy with a simpler implementation, something that just let's me return true in a delegate that checks if a date has an event, like: public boolean dateHasEvent(Date date). Then I can still have my own, styled list view below the calendar to show those events properly when the OnDateChangedListener fires.

Dates that have events - where the delegate function returned true - could simply be highlighted with a dot below the date. Much like https://github.com/jonathantribouharet/JTCalendar

@jlindenbaum I was trying to find an appropriate way to indicate a day had an event; thanks for the suggestion!

Does anyone else have input they would like to give for the API? If we are going to use the dot indicator, I'm supportive of the delegate pattern, but I see what I initially proposed as more extensible. Maybe a mix between the two and call it an EventAdapter? Though I'm not quite sure how that would work.

I'd prefer a lighter weight calendar utility, and handling my own event
listing / adapter. I'd be very happy with just a way to highlight that
there's something going on that day.

Since I personally want to handle the click and styling of the event
listing, and won't want to have to jam custom adapters into the calendar
view to do so.

On Wed, Mar 11, 2015 at 12:02 PM, Adam Koski [email protected]
wrote:

@jlindenbaum https://github.com/jlindenbaum I was trying to find an
appropriate way to indicate a day had an event; thanks for the suggestion!

Does anyone else have input they would like to give for the API? If we are
going to use the dot indicator, I'm supportive of the delegate pattern, but
I see what I initially proposed as more extensible. Maybe a mix between the
two and call it and EventAdapter? Though I'm not quite sure how that
would work.

—
Reply to this email directly or view it on GitHub
https://github.com/prolificinteractive/material-calendarview/issues/3#issuecomment-78324770
.

I think the dot indicator would be a good idea and it would be easy to put different kind of event simply by changing the color of the dot.
But as @jlindenbaum said we should be able to override the "dot adapter" by using an adapter of our own.

This is a very naive, and untested, implementation of how I imagine the flow. There is no caching, but that could be added. For every CalendarDay we call the EventDelegate that is implemented, most likely, in a Fragment. This naive implementation does not highlight the current day in any way. It's merely seeing if people would agree with this type of implementation.

https://github.com/jlindenbaum/material-calendarview/commit/15d0fb9a4e18408f9df97b2977b35b67f6e7e77e

Based off #21, I'd suggest changing EventsDelegate to something more appropriately named, perhaps CalendarDayConfigurationDelegate. I've been rolling with delegate, as it's not really a listener, but also not entirely a delegate. Help appreciated.

Functions in the delegate could now be public boolean calendarDayHasEvent(CalendarDay day) and public boolean calendarDayIsSelectable(CalendarDay day), or calendarDayIsEnabled(CalendarDay day). Any number of functions that allow us to configure the CalendarDay while it's being rendered.

selection_722
Hi @dandc87, can you update calendar view like this:

  • The dot or indicator below is a date which has event
  • The selected day is the day has red background
  • The current day is the day has red text color

I think it would be awesome to have events adding and deleting feature in this calendar. This is something that is implemented in Caldroid.
https://github.com/roomorama/Caldroid
We can even customize the appearance of events shown on Calender in Caldroid. And i would like the same sort of functionality here.

A more general solution would be to provide custom decorators to day views. I was working on a very simple implementation that allows you to do so https://github.com/angelpinheiro/material-calendarview/commit/7d7f1ce132544850366d71314dd29ce3d3e0f1ac. I have also updated the sample project with a new example that looks like this:

First you define your decorator, to decorate day views as you want:

public class HighlightDecorator implements DayViewDecorator{
    @Override
    public void decorate(DayView view,Context context) {
        view.setBackground(generateCircleDrawable(color));
    }
}

Then you tell calendar widget wich dates you want to decorate:

widget.addDayViewDecorator(new HighlightDecorator(), dates)
widget.addDayViewDecorator(new AnotherDecorator(), ...)

You can probably improve it in many ways, since I do not know very well the architecture of the library, but it's a starting point. I will do a pull request if you are interested!

I like the decorator idea @angelpinheiro, but it needs some work. Will you create a pull request so we can discuss some changes?

You can now use DayViewDecorator to show events!

Thanks for all , Awesome Work.

how i can add a new event like intent?

how can i add a text below a date?? (Can be event or reminder)

Yes, like can we popup a title or a text somehow for the decorated dates ??

Please Let me any idea How i can show all events on material calendar after getting from Google calendar API??

Please somebody give me the proper detailed code to add and view the event in this calander view

Was this page helpful?
0 / 5 - 0 ratings