isHasRemovestreamData = false; // changed by observer logic to indicate new data
isRetainObserverEvents = true; // enable retain logic in observer
try
{
for (int viewIndex = 0; viewIndex < views.length; viewIndex++) {
View view = views[viewIndex];
view.update(newData, oldData);
// first-X asymetric view post no insert stream for events that get dropped, remove these
if (newDataChildView != null) {
for (int i = 0; i < newData.length; i++) {
boolean found = false;
for (int j = 0; j < newDataChildView.length; j++) {
if (newDataChildView[i] == newData[i]) {
found = true;
break;
}
}
if (!found) {
removedByView[i][viewIndex] = true;
}
}
}
else {
for (int i = 0; i < newData.length; i++) {
removedByView[i][viewIndex] = true;
}
}
}
}
finally
{
isRetainObserverEvents = false;
}
// determine removed events, those that have a "true" in the remove by view index for all views
removalEvents.clear();
for (int i = 0; i < newData.length; i++) {
boolean allTrue = true;
for (int j = 0; j < views.length; j++) {
if (!removedByView[i][j]) {
allTrue = false;
break;
}
}
if (allTrue) {
removalEvents.add(newData[i]);
unionWindow.removeAll(newData[i]);
}
}
// remove if any
if (!removalEvents.isEmpty()) {
isDiscardObserverEvents = true;
EventBean[] viewOldData = removalEvents.toArray(new EventBean[removalEvents.size()]);
try
{
for (int j = 0; j < views.length; j++)
{
views[j].update(null, viewOldData);
}
}
finally
{
isDiscardObserverEvents = false;
}
}
// see if any child view has removed any events.
// if there was an insert stream, handle pushed-out events
if (isHasRemovestreamData)
{
List<EventBean> removedEvents = null;
// process each buffer
for (int i = 0; i < oldEventsPerView.length; i++)
{
if (oldEventsPerView[i] == null)
{
continue;
}
EventBean[] viewOldData = oldEventsPerView[i];
oldEventsPerView[i]= null; // clear entry
// remove events for union, if the last event was removed then add it
for (EventBean old : viewOldData)
{
boolean isNoMoreRef = unionWindow.remove(old);
if (isNoMoreRef)
{
if (removedEvents == null)
{
removalEvents.clear();
removedEvents = removalEvents;
}
removedEvents.add(old);
}
}
}
if (removedEvents != null)
{
oldData = removedEvents.toArray(new EventBean[removedEvents.size()]);
}
}
newEvents.clear();
for (int i = 0; i < newData.length; i++) {
if (!removalEvents.contains(newData[i])) {
newEvents.add(newData[i]);
}
}
EventBean[] newDataPosted = null;
if (!newEvents.isEmpty()) {
newDataPosted = newEvents.toArray(new EventBean[newEvents.size()]);
}
// indicate new and, possibly, old data
if ((newDataPosted != null) || (oldData != null)) {
updateChildren(newDataPosted, oldData);
}
}
// handle remove stream
else if (oldData != null)
{
isDiscardObserverEvents = true; // disable reaction logic in observer
try
{
for (View view : views)
{
view.update(null, oldData);
}
}
finally
{
isDiscardObserverEvents = false;