@Override protected ArrayList<PlaylistInfo> doInBackground(Void... arg0) { ArrayList<PlaylistInfo> playlists; try { playlists = RdioComm.getComm().getUserPlaylists(); } catch (ServiceCommException e) { err = e.getMessage(getActivity()); return null; } return playlists; }
@Override protected Void doInBackground(Void... args) { try { if (isCancelled()) return null; if (mIsRequest) RdioComm.getComm().retrieveRequestToken(getActivity()); else RdioComm.getComm().retrieveAccessTokens(mVerifier, getActivity()); } catch (ServiceCommException e) { err = e.getMessage(getActivity()); return null; } return null; }
@Override protected Void doInBackground(Void... params) { if (!RdioComm.getComm().isAuthorized()) { ServiceCommException e = new ServiceCommException(ServiceID.RDIO, ServiceErr.NOT_AUTH); err = e.getMessage(getActivity()); return null; } final AtomicInteger fetchCount = mFetchCount; final ArrayList<SongInfo> playlist = new ArrayList<SongInfo>(mPlaylist.subList(fetchCount.get(), mPlaylist.size())); for (SongInfo song : playlist) { if (isCancelled()) { return null; } try { mSongIds.add(RdioComm.getComm().queryTrackID(song.name, song.artist.name)); } catch (ServiceCommException e) { if (e.getErr() == ServiceErr.SONG_NOT_FOUND) { publishProgress(fetchCount.incrementAndGet()); Log.i( Util.APP, "Song [" + song.name + " - " + song.artist.name + "] not found in Rdio, ignoring..."); continue; } Log.w(Util.APP, "Failed to export playlist to Rdio!", e); err = e.getMessage(getActivity()); return null; } publishProgress(fetchCount.incrementAndGet()); } if (isCancelled()) { return null; } if (mSongIds.isEmpty()) { err = getString(R.string.no_song_found); return null; } publishProgress(-1); try { if (mChosenPlaylist.id != null) { // add songs to existing playlist, if id is given RdioComm.getComm().addToPlaylist(mChosenPlaylist.id, mSongIds, getActivity()); } else { // create new playlist if the name is given RdioComm.getComm().createPlaylist(mChosenPlaylist.name, mSongIds, getActivity()); } } catch (ServiceCommException e) { err = e.getMessage(getActivity()); } return null; }