예제 #1
0
 private void setResultIds(Item item, int index) {
   if (item != null && item instanceof CatalogItem) {
     CatalogItem catalogItem = (CatalogItem) item;
     if (catalogItem.IsChecked) {
       int insertIndex = index <= 0 ? -1 : (index - 1);
       if (mySelectedItems.contains(catalogItem)) {
         mySelectedItems.remove(catalogItem);
       }
       if (insertIndex >= 0) {
         mySelectedItems.add(insertIndex, catalogItem);
       } else {
         mySelectedItems.add(catalogItem);
       }
     } else {
       mySelectedItems.remove(catalogItem);
     }
     final ArrayList<String> ids = new ArrayList<String>();
     for (Item selectedItem : mySelectedItems) {
       if (selectedItem instanceof CatalogItem) {
         final CatalogItem ci = (CatalogItem) selectedItem;
         if (ci.IsChecked) {
           ids.add(ci.Id);
         }
       }
     }
     setResult(
         RESULT_OK,
         new Intent()
             .putStringArrayListExtra(NetworkLibraryActivity.ENABLED_CATALOG_IDS_KEY, ids));
   }
 }
예제 #2
0
  public void updateVisibility() {
    final LinkedList<FBTree> toRemove = new LinkedList<FBTree>();

    ListIterator<FBTree> nodeIterator = subTrees().listIterator();
    FBTree currentNode = null;
    int nodeCount = 0;

    for (int i = 0; i < ChildrenItems.size(); ++i) {
      NetworkLibraryItem currentItem = ChildrenItems.get(i);
      if (!(currentItem instanceof NetworkCatalogItem)) {
        continue;
      }
      boolean processed = false;
      while (currentNode != null || nodeIterator.hasNext()) {
        if (currentNode == null) {
          currentNode = nodeIterator.next();
        }
        if (!(currentNode instanceof NetworkCatalogTree)) {
          currentNode = null;
          ++nodeCount;
          continue;
        }
        NetworkCatalogTree child = (NetworkCatalogTree) currentNode;
        if (child.Item == currentItem) {
          switch (child.Item.getVisibility()) {
            case B3_TRUE:
              child.updateVisibility();
              break;
            case B3_FALSE:
              toRemove.add(child);
              break;
            case B3_UNDEFINED:
              child.clear();
              child.ChildrenItems.clear();
              break;
          }
          currentNode = null;
          ++nodeCount;
          processed = true;
          break;
        } else {
          boolean found = false;
          for (int j = i + 1; j < ChildrenItems.size(); ++j) {
            if (child.Item == ChildrenItems.get(j)) {
              found = true;
              break;
            }
          }
          if (!found) {
            toRemove.add(currentNode);
            currentNode = null;
            ++nodeCount;
          } else {
            break;
          }
        }
      }
      final int nextIndex = nodeIterator.nextIndex();
      if (!processed
          && NetworkTreeFactory.createNetworkTree(this, currentItem, nodeCount) != null) {
        ++nodeCount;
        nodeIterator = subTrees().listIterator(nextIndex + 1);
      }
    }

    while (currentNode != null || nodeIterator.hasNext()) {
      if (currentNode == null) {
        currentNode = nodeIterator.next();
      }
      if (currentNode instanceof NetworkCatalogTree) {
        toRemove.add(currentNode);
      }
      currentNode = null;
    }

    for (FBTree tree : toRemove) {
      tree.removeSelf();
    }
  }
예제 #3
0
 @Override
 public void removeItems(Set<NetworkLibraryItem> items) {
   ChildrenItems.removeAll(items);
   super.removeItems(items);
 }