/** * Pre-load other album (done outside the EDT). * * @throws Exception the exception */ void preFetchSimilarArtists() throws Exception { // Perform last.fm calls similar = LastFmService.getInstance().getSimilarArtists(artist); // artists is null for void (unknown) similar artists if (similar != null && similar.getArtists() != null) { List<ArtistInfo> artists = similar.getArtists(); for (ArtistInfo similarArtist : artists) { // stop this list of albums if there was another file launched in the meantime, another // refresh will take place anyway String artistUrl = similarArtist.getImageUrl(); if (StringUtils.isBlank(artistUrl)) { continue; } // Download thumb URL remote = new URL(artistUrl); // Download the picture and store file reference (to // generate the popup thumb for ie) DownloadManager.downloadToCache(remote); } } }
/** * Return the result panel for lastFM information. * * @param type * @param artistView * @return the last fm suggestions panel */ JScrollPane getLastFMSuggestionsPanel(SuggestionType type, boolean artistView) { FlowScrollPanel flowPanel = new FlowScrollPanel(); JScrollPane jsp = new JScrollPane( flowPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBorder(null); flowPanel.setScroller(jsp); flowPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); if (type == SuggestionType.OTHERS_ALBUMS) { if (albums != null && albums.getAlbums().size() > 0) { for (AlbumInfo album : albums.getAlbums()) { AbstractThumbnail thumb = new LastFmAlbumThumbnail(album); thumb.setArtistView(artistView); thumb.populate(); if (thumb.getIcon() != null) { thumb.getIcon().addMouseListener(new ThumbMouseListener()); flowPanel.add(thumb); } } } // No result found else { return new JScrollPane(getNothingFoundPanel()); } } else if (type == SuggestionType.SIMILAR_ARTISTS) { if (similar != null) { List<ArtistInfo> artists = similar.getArtists(); for (ArtistInfo similarArtist : artists) { AbstractThumbnail thumb = new LastFmArtistThumbnail(similarArtist); thumb.setArtistView(artistView); thumb.populate(); if (thumb.getIcon() != null) { thumb.getIcon().addMouseListener(new ThumbMouseListener()); flowPanel.add(thumb); } } } // No result found else { return new JScrollPane(getNothingFoundPanel()); } } return jsp; }