Search in sources :

Example 1 with GroupInfo

use of dev.dworks.apps.anexplorer.model.GroupInfo in project AnExplorer by 1hakr.

the class RootsExpandableAdapter method processRoots.

private void processRoots(Collection<RootInfo> roots) {
    List<GroupInfo> groupRoots = new ArrayList<>();
    final List<Item> home = new ArrayList<>();
    final List<Item> phone = new ArrayList<>();
    final List<Item> recent = new ArrayList<>();
    final List<Item> connection = new ArrayList<>();
    final List<Item> rooted = new ArrayList<>();
    final List<Item> appbackup = new ArrayList<>();
    final List<Item> usb = new ArrayList<>();
    final List<Item> storage = new ArrayList<>();
    final List<Item> secondaryStorage = new ArrayList<>();
    final List<Item> network = new ArrayList<>();
    final List<Item> apps = new ArrayList<>();
    final List<Item> libraryMedia = new ArrayList<>();
    final List<Item> libraryNonMedia = new ArrayList<>();
    final List<Item> folders = new ArrayList<>();
    final List<Item> bookmarks = new ArrayList<>();
    for (RootInfo root : roots) {
        if (root.isHome()) {
            home.add(new RootItem(root));
        } else if (root.isRecents()) {
            if (recent.size() == 0) {
                recent.add(new RootItem(root));
            }
        } else if (root.isConnections()) {
            connection.add(new RootItem(root));
        } else if (root.isRootedStorage()) {
            rooted.add(new RootItem(root));
        } else if (root.isPhoneStorage()) {
            phone.add(new RootItem(root));
        } else if (root.isAppBackupFolder()) {
            appbackup.add(new RootItem(root));
        } else if (root.isUsbStorage()) {
            usb.add(new RootItem(root));
        } else if (RootInfo.isLibraryMedia(root)) {
            libraryMedia.add(new RootItem(root));
        } else if (RootInfo.isLibraryNonMedia(root)) {
            libraryNonMedia.add(new RootItem(root));
        } else if (RootInfo.isFolder(root)) {
            folders.add(new RootItem(root));
        } else if (RootInfo.isBookmark(root)) {
            bookmarks.add(new BookmarkItem(root));
        } else if (RootInfo.isStorage(root)) {
            if (root.isSecondaryStorage()) {
                secondaryStorage.add(new RootItem(root));
            } else {
                storage.add(new RootItem(root));
            }
        } else if (RootInfo.isApps(root)) {
            apps.add(new RootItem(root));
        } else if (RootInfo.isNetwork(root)) {
            network.add(new RootItem(root));
        }
    }
    if (!home.isEmpty() || !storage.isEmpty() || !phone.isEmpty() || !rooted.isEmpty()) {
        home.addAll(storage);
        home.addAll(secondaryStorage);
        home.addAll(usb);
        home.addAll(phone);
        home.addAll(rooted);
        groupRoots.add(new GroupInfo("Storage", home));
    }
    if (!network.isEmpty()) {
        network.addAll(connection);
        groupRoots.add(new GroupInfo("Network", network));
    } else if (!connection.isEmpty()) {
        groupRoots.add(new GroupInfo("Network", connection));
    }
    if (!apps.isEmpty()) {
        if (!appbackup.isEmpty()) {
            apps.addAll(appbackup);
        }
        groupRoots.add(new GroupInfo("Apps", apps));
    }
    if (!libraryMedia.isEmpty() || !libraryNonMedia.isEmpty()) {
        recent.addAll(libraryMedia);
        recent.addAll(libraryNonMedia);
        groupRoots.add(new GroupInfo("Library", recent));
    } else if (!recent.isEmpty()) {
        groupRoots.add(new GroupInfo("Library", recent));
    }
    if (!folders.isEmpty()) {
        folders.addAll(bookmarks);
        groupRoots.add(new GroupInfo("Folders", folders));
    }
    group.clear();
    group.addAll(groupRoots);
}
Also used : Item(dev.dworks.apps.anexplorer.fragment.RootsFragment.Item) RootItem(dev.dworks.apps.anexplorer.fragment.RootsFragment.RootItem) BookmarkItem(dev.dworks.apps.anexplorer.fragment.RootsFragment.BookmarkItem) GroupItem(dev.dworks.apps.anexplorer.fragment.RootsFragment.GroupItem) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) GroupInfo(dev.dworks.apps.anexplorer.model.GroupInfo) RootItem(dev.dworks.apps.anexplorer.fragment.RootsFragment.RootItem) ArrayList(java.util.ArrayList) BookmarkItem(dev.dworks.apps.anexplorer.fragment.RootsFragment.BookmarkItem)

Aggregations

BookmarkItem (dev.dworks.apps.anexplorer.fragment.RootsFragment.BookmarkItem)1 GroupItem (dev.dworks.apps.anexplorer.fragment.RootsFragment.GroupItem)1 Item (dev.dworks.apps.anexplorer.fragment.RootsFragment.Item)1 RootItem (dev.dworks.apps.anexplorer.fragment.RootsFragment.RootItem)1 GroupInfo (dev.dworks.apps.anexplorer.model.GroupInfo)1 RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)1 ArrayList (java.util.ArrayList)1