Package co.arcs.groove.basking.task.BuildSyncPlanTask.SyncPlan

Examples of co.arcs.groove.basking.task.BuildSyncPlanTask.SyncPlan.Item


        Builder<Item> syncPlanItems = ImmutableList.builder();

        for (Integer id : wantedSongs.keySet()) {
            if (existingSongs.containsKey(id)) {
                // Wanted song already exists, so leave as is
                syncPlanItems.add(new Item(existingSongs.get(id),
                        Action.LEAVE,
                        wantedSongs.get(id)));
                existingSongs.remove(id);
            } else {
                // Wanted song is absent, so download
                syncPlanItems.add(new Item(new File(syncDir,
                        Utils.getDiskName(wantedSongs.get(id))),
                        Action.DOWNLOAD,
                        wantedSongs.get(id)
                ));
            }
        }

        // Remaining songs are present but unwanted, so delete
        for (Integer id : existingSongs.keySet()) {
            syncPlanItems.add(new Item(existingSongs.get(id), Action.DELETE, null));
        }
        return new SyncPlan(syncPlanItems.build());
    }
View Full Code Here


            bus.post(new BuildSyncPlanProgressChangedEvent(this, 0, songs.size()));

            for (Song song : songs) {
                if (cacheMap.containsKey(song.getId())) {
                    // Wanted song is in cache, so leave as is
                    items.add(new Item(new File(syncDir, cacheMap.get(song.getId())),
                            Action.LEAVE,
                            song));
                    cacheMap.remove(song.getId());
                } else {
                    // Wanted song is absent, so download
                    items.add(new Item(new File(syncDir, Utils.getDiskName(song)),
                            Action.DOWNLOAD,
                            song));
                }
                bus.post(new BuildSyncPlanProgressChangedEvent(this, ++progress, songs.size()));
            }

            // Unwanted stuff that's in the cache should be removed
            for (String fileName : cacheMap.values()) {
                items.add(new Item(new File(syncDir, fileName), Action.DELETE, null));
            }

            return new SyncPlan(items.build());
        } else {
            return null;
View Full Code Here

TOP

Related Classes of co.arcs.groove.basking.task.BuildSyncPlanTask.SyncPlan.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.