示例#1
0
 protected static Object addUpgradeToDequeIfPopulated(Object holder, EventBean theEvent) {
   if (holder == null) {
     return theEvent;
   } else if (holder instanceof Deque) {
     Deque<EventBean> deque = (Deque<EventBean>) holder;
     deque.add(theEvent);
     return deque;
   } else {
     ArrayDeque<EventBean> deque = new ArrayDeque<EventBean>(4);
     deque.add((EventBean) holder);
     deque.add(theEvent);
     return deque;
   }
 }
示例#2
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;
 }