Skip to content

Commit

Permalink
Fixed an update issue for recurring events in the AllDayView.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Oct 12, 2022
1 parent dcf18e3 commit 7358c7e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,6 @@ private List<EntryViewBase> findEntryViews(Entry<?> entry) {
.collect(Collectors.toList());
}

private Optional<EntryViewBase> findRecurrenceEntryView(Entry<?> entry) {
List<EntryViewBase> collect = entryViewGroup.getChildren().stream()
.map(node -> (EntryViewBase) node)
.filter(e -> e.getEntry().isRecurrence())
.filter(e -> e.getEntry().getRecurrenceId().equals(entry.getRecurrenceId()))
.collect(Collectors.toList());

if (collect.isEmpty()) {
return Optional.empty();
}

return Optional.of(collect.get(0));
}

private boolean removeEntryViews(Entry<?> entry, String reason) {
if (reason != null) {
LoggingDomain.VIEW.fine("removing entry, reason = " + reason + ", date = " + getSkinnable().getDate());
Expand Down Expand Up @@ -186,12 +172,16 @@ private Map<LocalDate, Entry<?>> findRecurrenceEntries(Entry<?> entry) {
Calendar calendar = entry.getCalendar();
LocalDate startDate = getLoadStartDate();
LocalDate endDate = getLoadEndDate();

Map<LocalDate, List<Entry<?>>> entries = calendar.findEntries(startDate, endDate, getZoneId());
Map<LocalDate, Entry<?>> result = new HashMap<>();

entries.forEach((date, list) -> {
if (!list.isEmpty()) {
Optional<Entry<?>> first = list.stream().filter(e -> e.getStartDate().equals(date)).findFirst();
Optional<Entry<?>> first = list.stream()
.filter(e -> e.getId().equals(entry.getId()))
.filter(e -> e.getStartDate().equals(date))
.findFirst();
if (first.isPresent()) {
result.put(date, first.get());
}
Expand Down Expand Up @@ -241,6 +231,36 @@ protected void calendarChanged(Calendar calendar) {
updateEntries("calendar changed");
}

@Override
protected void entryTitleChanged(CalendarEvent evt) {
LoggingDomain.VIEW.fine("handle entry title changed, date = " + getSkinnable().getDate());
Entry<?> entry = evt.getEntry();
if (entry.isFullDay()) {
// no need to check for relevance, probably faster to just look for entry views
findEntryViews(entry).forEach(entryView -> entryView.getEntry().setTitle(evt.getEntry().getTitle()));
}
}

@Override
protected void entryLocationChanged(CalendarEvent evt) {
LoggingDomain.VIEW.fine("handle entry location changed, date = " + getSkinnable().getDate());
Entry<?> entry = evt.getEntry();
if (entry.isFullDay()) {
// no need to check for relevance, probably faster to just look for entry views
findEntryViews(entry).forEach(entryView -> entryView.getEntry().setLocation(evt.getEntry().getLocation()));
}
}

@Override
protected void entryUserObjectChanged(CalendarEvent evt) {
LoggingDomain.VIEW.fine("handle entry user object changed, date = " + getSkinnable().getDate());
Entry<?> entry = evt.getEntry();
if (entry.isFullDay()) {
// no need to check for relevance, probably faster to just look for entry views
findEntryViews(entry).forEach(entryView -> entryView.getEntry().setUserObject(evt.getEntry().getUserObject()));
}
}

@Override
protected void entryCalendarChanged(CalendarEvent evt) {
LoggingDomain.VIEW.fine("handle entry calendar changed, date = " + getSkinnable().getDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ private void calendarChanged(CalendarEvent evt) {
entryCalendarChanged(evt);
} else if (eventType.equals(CalendarEvent.ENTRY_TITLE_CHANGED)) {
entryTitleChanged(evt);
} else if (eventType.equals(CalendarEvent.ENTRY_LOCATION_CHANGED)) {
entryLocationChanged(evt);
} else if (eventType.equals(CalendarEvent.ENTRY_USER_OBJECT_CHANGED)) {
entryUserObjectChanged(evt);
} else if (eventType.equals(CALENDAR_CHANGED)) {
calendarChanged(evt.getCalendar());
}
Expand All @@ -170,6 +174,12 @@ protected void entryCalendarChanged(CalendarEvent evt) {
protected void entryTitleChanged(CalendarEvent evt) {
}

protected void entryLocationChanged(CalendarEvent evt) {
}

protected void entryUserObjectChanged(CalendarEvent evt) {
}

protected void calendarChanged(Calendar calendar) {
}

Expand Down

0 comments on commit 7358c7e

Please sign in to comment.