v.blade.library.Playlist.setArtLoading()

Here are the examples of the java api v.blade.library.Playlist.setArtLoading() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

18 Source : Spotify.java
with GNU General Public License v3.0
from Valou3433

@Override
public void registerCachedSongs() {
    if (!LibraryService.configured)
        return;
    spotifyCachedToLoadArt = new ArrayList<>();
    spotifyCachedToLoadArtUris = new HashMap<>();
    System.out.println("[BLADE-SPOTIFY] Registering cached songs...");
    try {
        if (spotifyCacheFile.exists()) {
            // spotify library
            BufferedReader spr = new BufferedReader(new FileReader(spotifyCacheFile));
            String[] tp = spr.readLine().split(CACHE_SEPARATOR);
            int cache_version = 0;
            if (tp[0].equals("Blade") && tp[1].equals("edalB") && tp[2].equals("SPCACHE")) {
                // We have cache file from Blade >= 1.5, retrieve version from file to know how to read it
                cache_version = Integer.parseInt(tp[3]);
            } else {
                // cache version is 1 : < Blade 1.5
                cache_version = 1;
                // register first song
                Song song = LibraryService.registerSong(tp[2], tp[1], Integer.parseInt(tp[4]), 0, Long.parseLong(tp[5]), tp[0], new SongSources.SongSource(tp[6], SOURCE_SPOTIFY));
                song.setFormat(tp[3]);
                if (!song.getAlbum().hasArt() && !song.getAlbum().getArtLoading()) {
                    spotifyCachedToLoadArt.add(song.getAlbum());
                    song.getAlbum().setArtLoading();
                }
            }
            while (spr.ready()) {
                tp = spr.readLine().split(CACHE_SEPARATOR);
                Song song = LibraryService.registerSong(tp[2], tp[1], Integer.parseInt(tp[4]), 0, Long.parseLong(tp[5]), tp[0], new SongSources.SongSource(tp[6], SOURCE_SPOTIFY));
                song.setFormat(tp[3]);
                if (!song.getAlbum().hasArt() && !song.getAlbum().getArtLoading()) {
                    // the image is supposed to be cached locally, so no need to provide URL
                    // if user removed cache, this fails ; cache version 2 should take care of that
                    spotifyCachedToLoadArt.add(song.getAlbum());
                    if (cache_version == 2 && tp.length > 7)
                        spotifyCachedToLoadArtUris.put(song.getAlbum(), tp[7]);
                    else
                        spotifyCachedToLoadArtUris.put(song.getAlbum(), "");
                    song.getAlbum().setArtLoading();
                }
            }
            spr.close();
            // spotify playlists
            if (spotifyPlaylistsCache.exists()) {
                for (File f : spotifyPlaylistsCache.listFiles()) {
                    ArrayList<Song> thisList = new ArrayList<>();
                    BufferedReader sppr = new BufferedReader(new FileReader(f));
                    String id = sppr.readLine();
                    boolean isMine = Boolean.parseBoolean(sppr.readLine());
                    String owner = null;
                    String ownerID = null;
                    if (!isMine) {
                        owner = sppr.readLine();
                        ownerID = sppr.readLine();
                    }
                    boolean isCollab = Boolean.parseBoolean(sppr.readLine());
                    while (sppr.ready()) {
                        tp = sppr.readLine().split(CACHE_SEPARATOR);
                        Song song = LibraryService.SAVE_PLAYLISTS_TO_LIBRARY ? LibraryService.registerSong(tp[2], tp[1], Integer.parseInt(tp[4]), 0, Long.parseLong(tp[5]), tp[0], new SongSources.SongSource(tp[6], SOURCE_SPOTIFY)) : LibraryService.getSongHandle(tp[0], tp[1], tp[2], Long.parseLong(tp[5]), new SongSources.SongSource(tp[6], SOURCE_SPOTIFY), Integer.parseInt(tp[4]), 0);
                        song.setFormat(tp[3]);
                        thisList.add(song);
                        if (!song.getAlbum().hasArt() && !song.getAlbum().getArtLoading()) {
                            // the image is supposed to be cached locally, so no need to provide URL
                            if (cache_version == 2 && tp.length > 7)
                                spotifyCachedToLoadArtUris.put(song.getAlbum(), tp[7]);
                            else
                                spotifyCachedToLoadArtUris.put(song.getAlbum(), "");
                            spotifyCachedToLoadArt.add(song.getAlbum());
                            song.getAlbum().setArtLoading();
                        }
                    }
                    sppr.close();
                    Playlist p = new Playlist(f.getName(), thisList);
                    if (!isMine)
                        p.setOwner(owner, ownerID);
                    if (isCollab)
                        p.setCollaborative();
                    spotifyCachedToLoadArt.add(p);
                    p.setArtLoading();
                    p.getSources().addSource(new SongSources.SongSource(id, SOURCE_SPOTIFY));
                    LibraryService.getPlaylists().add(p);
                }
            }
        }
    } catch (IOException e) {
        Log.println(Log.ERROR, "[BLADE-SPOTIFY]", "Cache restore : IOException");
        e.printStackTrace();
    }
    System.out.println("[BLADE-SPOTIFY] Cached songs registered.");
}