Ejemplo n.º 1
0
  /**
   * Removes a {@link ResourceFolder} associated with the specified {@link IAbstractFolder}.
   *
   * @param type The type of the folder
   * @param removedFolder the IAbstractFolder object.
   * @param context the scanning context
   * @return the {@link ResourceFolder} that was removed, or null if no matches were found.
   */
  @Nullable
  public ResourceFolder removeFolder(
      @NonNull ResourceFolderType type,
      @NonNull IAbstractFolder removedFolder,
      @Nullable ScanningContext context) {
    ensureInitialized();

    // get the list of folders for the resource type.
    List<ResourceFolder> list = mFolderMap.get(type);

    if (list != null) {
      int count = list.size();
      for (int i = 0; i < count; i++) {
        ResourceFolder resFolder = list.get(i);
        IAbstractFolder folder = resFolder.getFolder();
        if (removedFolder.equals(folder)) {
          // we found the matching ResourceFolder. we need to remove it.
          list.remove(i);

          // remove its content
          resFolder.dispose(context);

          return resFolder;
        }
      }
    }

    return null;
  }
Ejemplo n.º 2
0
  /**
   * Returns the {@link ResourceFolder} associated with a {@link IAbstractFolder}.
   *
   * @param folder The {@link IAbstractFolder} object.
   * @return the {@link ResourceFolder} or null if it was not found.
   */
  @Nullable
  public ResourceFolder getResourceFolder(@NonNull IAbstractFolder folder) {
    ensureInitialized();

    Collection<List<ResourceFolder>> values = mFolderMap.values();

    for (List<ResourceFolder> list : values) {
      for (ResourceFolder resFolder : list) {
        IAbstractFolder wrapper = resFolder.getFolder();
        if (wrapper.equals(folder)) {
          return resFolder;
        }
      }
    }

    return null;
  }