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
Problem with set event #52
Comments
Because that WeekViewEvent constructor uses a more logical month index: januari = 1. But you can construct it using @alamkanak this issue can be closed. |
It's ok? |
yes, but I don't see why you don't just pass in the calendar objects. Now the calendar objects are "destructed" by you to be constructed again in the library... |
new WeekViewEvent(1, getEventTitle(startTime), startTime, endTime) |
Have you taken a look at the sample app? https://github.com/alamkanak/Android-Week-View/blob/master/sample/src/main/java/com/alamkanak/weekview/sample/MainActivity.java#L107 |
Yes it works, but i have timestamp and I don't know how use timestamp. |
Calender start = Calender.getInstance(); events.add(new WeekViewEvent(1, getEventTitle(start), startTime, endTime)) PS remember that the newMonth from the onMonthChangeListener is also 1-based instead of 0-based. |
Still don't work:
|
end.setTimeInMillis(1421334000L); You were passing in an event that last for 0 milliseconds. |
14213304000 = Tue, 26 May 2420 20:00:00 GMT |
I meant => |
When i set like this: |
Why when I set event like this:
calendar views like this: |
onMonthChange is called three times (when you don't scroll)
That's why it's being shown multiple times. (You have to take in account the newMonth and newYear variables. They are there for a reason) |
so I do not think it should be? |
I really do not know how I set the event for example 15-01-2015. So that two months after scrolling forward and return to the event, was displayed only once? |
just only add it if newMonth==1 and newYear==2015 |
This is a bad idea, because I have list with dates, ie: 15-01-2015, 23-03-2015, 07-06-2015...and I have set all dates. |
This seriously doesn't belong in an issue for this library. Just only add the events which have a matching month and year (matching = event falls in the month that is requested by newMonth and newYear: event.getMonth() == newMonth && event.getYear() == newYear). That's what I am saying. |
Please show me example. |
Remember this is pseudo-code, not real java code weekviewEvents = new ArrayList()
for(Event event : allEvents){
if(event.getMonth() == newMonth && event.getYear() == newYear){
weekviewEvents.add(event)
}
}
return weekviewEvents |
This is my code, event don't show:
|
How many times do I need to say that newMonth is 1-based and Calendar is 0-based? => |
Sorry my fault, now i have that code:
and my calendar look like this |
I'm guessing you should pass in a different id for the second event... |
I change id and doesn't work. |
you have to create new instances of the Calendar object (startTime, endTime) for your second event, otherwise you change the time of the first event too. |
Yes, caske33's answer is right. I had a similar problem and I lost about half day of work to resolve it. Btw i don't understand why this API preloads 3 months events. |
The reason why there's a 3 month preload is to smooth the swiping. This way the library won't have to wait for you to provide the events when the user scrolls to the next month, they will already be loaded. And most people don't match all their events with the nextMonth and nextYear variables but they load their events based on those variables (e.g. they look in the database for the events that fall within the month requested) |
Thank you, i undestand. |
Answer from @caske33 is correct |
add missing case
Hello, I have 2 dates:
15-01-2015 14:00, timestamp: 1421330400
15-01-2015 15:00, timestamp: 1421334000
and I want to set Event like this:
@OverRide
public List onMonthChange(int newYear, int newMonth) {
but event don't show on calendar, how to do this?
The text was updated successfully, but these errors were encountered: