Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events on day 1 of the month doesn't appear #12

Closed
abanjo opened this issue Aug 14, 2015 · 6 comments
Closed

Events on day 1 of the month doesn't appear #12

abanjo opened this issue Aug 14, 2015 · 6 comments
Assignees
Labels

Comments

@abanjo
Copy link

abanjo commented Aug 14, 2015

Hi,
i've imported your beautiful calendar in my project. I need to show events on it and the official one from Google doesn't have this feature,
It works well but i want to signal you some issue i found :

  1. On day 1 the small indicator is not shown. why?:
    if(!isSameDayAsCurrentDay && dayOfMonth != 1){

  2. I'm getting the events from my server via Volley. So when i receive a respose ( async process ) i add event with this line of code ( calendar is already created in the activity ).
    context.compactCalendarView.addEvent(new CalendarDayEvent(nb.getDate().getTime(), Color.argb(255, 0, 0, 0)));

I do this on every month change event!

But at first render the small indicators are not present. Only if i touch the calendar or try to slide it they appears!
To avoid it i've added this line of code after all "addEvent" :
context.compactCalendarView.setCurrentDate(new Date());
This is for me a way to "refresh" the calendar.

This works only for the first time ... on subsequently month change it creates some problems to the visualization of the days in the calendar ( ex: i'm in July but i see day and events of another month )

I think that the problem is due to the fact that i get data in a second moment an not in the activity when the calendar is created.

Do you have any suggestions?

Thanks!

@SundeepK
Copy link
Owner

  1. On day 1 the small indicator is not shown. why?:
    Because that's how I programmed it :). I thought highlighting day 1 was more important than showing an event but I can see this is a problem. Easily fixed. I can probably change it so that it highlights both.

  2. That is because CompactCalendarView does not refresh the view when adding an event. Calling setDate will refresh the view. Call compactCalendarView.invalidate() might be nicer once you have added enough events. The problem is refreshing the view on add event method is that it will force the calendar to redraw. So if you add 1000 events, it will redraw 1000 times. I always thought exposing a method like addEvents(List<DayEvent> event); which would automatically refresh. I should document in java code manual refresh is required when adding single event.

Seeing day events from another month should not happen. No matter when it's loaded. As long as the date you use is correct. E.g. If you want to add events for next month. The epochTime you pass in should be for next month. CompactCalendarView does not use the current month for any date calculations.

If these conditions are met then this indicates some problem. Unfortunately, I cannot fix these problems until at least a week since I'm going off on holiday. So no commits until I'm back :(.

@abanjo
Copy link
Author

abanjo commented Aug 14, 2015

SundeepK, thanks for your answer!

  1. Ok! In my implementation i've used this color for the first day of the month :
    app:compactCalendarFirstDayOfMonthBackgroundColor="#992886d4"
    but it doesn't work ... so why i've noticed that the small indicator was empty.
    Using this way, instead, the first day is highlighted :
    app:compactCalendarFirstDayOfMonthBackgroundColor="#62aae5"

So at moment this problem is not so important :-)

  1. I can confirm you that if i call :
    context.compactCalendarView.setCurrentDate(new Date());
    some times the month switch to the "current month" ( now to August ). Debugging, this happens exactly on this line of code.
    I'm not sure but i think that this happens if the "new" month to render doesn't have any events to show. Months that have almost 1 event are ok!.

When i get the data from my server, first i cicle on all events and i call the "addEvent" method ... after that i call the SetCurrentDate ... so i do this only 1 time also with 100 events ;-)
Having a refresh method will be nice! At the moment i have no way to perform it without side effect ( like the SetCurrentDate ).

Don't worry for the fix ... and have a nice holiday!

Thanks for your library!

@SundeepK
Copy link
Owner

Umm interesting. I will look into this when I have the time. Did you try invalidate() method to refresh the view?

@abanjo
Copy link
Author

abanjo commented Aug 14, 2015

This works!!!
The invalidate() method refresh the view and have no side effect! :-)
Thanks very much!

@SundeepK
Copy link
Owner

No problem. I will look into these other problems you have noticed. I'm guessing the java calendar is getting in some inconsistent state when you call setDate() after adding some events. Java Calendar class is such a pain to use :(.

@SundeepK SundeepK added the bug label Aug 14, 2015
@SundeepK SundeepK self-assigned this Aug 14, 2015
@abanjo
Copy link
Author

abanjo commented Aug 14, 2015

Yes i know!
SundeepK, you are very kind :-)
Thanks for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants