Example #1
0
 @Override
 public boolean removeView(View view) {
   if (!(view instanceof GroupableView)) {
     super.removeView(view);
   }
   boolean removed = super.removeView(view);
   if (!removed) {
     return false;
   }
   if (!hasViews()) {
     subViewsPerKey.clear();
     return true;
   }
   GroupableView removedView = (GroupableView) view;
   Deque<Object> removedKeys = null;
   for (Map.Entry<Object, Object> entry : subViewsPerKey.entrySet()) {
     Object value = entry.getValue();
     if (value instanceof View) {
       GroupableView subview = (GroupableView) value;
       if (compareViews(subview, removedView)) {
         if (removedKeys == null) {
           removedKeys = new ArrayDeque<Object>();
         }
         removedKeys.add(entry.getKey());
       }
     } else if (value instanceof List) {
       List<View> subviews = (List<View>) value;
       for (int i = 0; i < subviews.size(); i++) {
         GroupableView subview = (GroupableView) subviews.get(i);
         if (compareViews(subview, removedView)) {
           subviews.remove(i);
           if (subviews.isEmpty()) {
             if (removedKeys == null) {
               removedKeys = new ArrayDeque<Object>();
             }
             removedKeys.add(entry.getKey());
           }
           break;
         }
       }
     }
   }
   if (removedKeys != null) {
     for (Object key : removedKeys) {
       subViewsPerKey.remove(key);
     }
   }
   return true;
 }
Example #2
0
 public void visitViewContainer(ViewDataVisitorContained viewDataVisitor) {
   viewDataVisitor.visitPrimary(VIEWNAME, subViewsPerKey.size());
   for (Map.Entry<Object, Object> entry : subViewsPerKey.entrySet()) {
     GroupByViewImpl.visitView(viewDataVisitor, entry.getKey(), entry.getValue());
   }
 }