kaaes.spotify.webapi.android.models.Tracks Java Examples
The following examples show how to use
kaaes.spotify.webapi.android.models.Tracks.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpotifyManagerImpl.java From mirror with Apache License 2.0 | 6 votes |
@Override public void play(@NonNull List<String> trackUris, @NonNull Listener listener) { mListener = listener; if (mService == null || trackUris.isEmpty()) { mListener.onPlaylistEnd(); return; } final String trackIds = stream(trackUris) .map(t -> t.replaceAll("spotify:track:", "")) .reduce((t, u) -> t + "," + u) .get(); mService.getTracks(trackIds, new Callback<Tracks>() { @Override public void success(Tracks tracks, Response response) { play(tracks); } @Override public void failure(RetrofitError error) { Timber.e(error, "Problem retrieving the tracks information"); } }); }
Example #2
Source File: Pasta.java From Pasta-for-Spotify with Apache License 2.0 | 6 votes |
@Nullable public ArrayList<TrackListData> getTracks(ArtistListData data) throws InterruptedException { Tracks tracks = null; for (int i = 0; tracks == null && i < PreferenceUtils.getRetryCount(this); i++) { try { tracks = spotifyService.getArtistTopTrack(data.artistId, Locale.getDefault().getCountry()); } catch (Exception e) { e.printStackTrace(); if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200); else break; } } if (tracks == null) return null; ArrayList<TrackListData> trackList = new ArrayList<>(); for (Track track : tracks.tracks) { trackList.add(new TrackListData(track)); } return trackList; }
Example #3
Source File: SpotifyManagerImpl.java From mirror with Apache License 2.0 | 5 votes |
private void play(final Tracks tracks) { final List<String> trackUris = stream(tracks.tracks) .filter(track -> track != null && track.uri != null) .map(track -> track.uri) .collect(toList()); if (trackUris.isEmpty()) { mListener.onPlaylistEnd(); return; } Timber.d("trackUris %s", trackUris); stream(trackUris).skip(1).forEach((Action1<String>) u -> mPlayer.queue(mOperationCallback, u)); mCurrentUri = trackUris.get(0); mPlayer.playUri(mOperationCallback, mCurrentUri, 0, 0); }
Example #4
Source File: SpotifyServiceAndroidTest.java From spotify-web-api-android with MIT License | 5 votes |
@Test public void getArtistTopTracks() throws Exception { Tracks payload = mService.getArtistTopTrack("54KCNI7URCrG6yjQK3Ukow", "SE"); Request request = new Request.Builder() .get() .url("https://api.spotify.com/v1/artists/54KCNI7URCrG6yjQK3Ukow/top-tracks?country=SE") .build(); Response response = mClient.newCall(request).execute(); assertEquals(200, response.code()); assertThat(payload, JsonEquals.jsonEquals(response.body().string())); }
Example #5
Source File: SpotifyServiceTest.java From spotify-web-api-android with MIT License | 5 votes |
@Test public void shouldGetArtistTopTracksTracks() throws Exception { String body = TestUtils.readTestData("tracks-for-artist.json"); Tracks fixture = mGson.fromJson(body, Tracks.class); Response response = TestUtils.getResponseFromModel(fixture, Tracks.class); when(mMockClient.execute(isA(Request.class))).thenReturn(response); Tracks tracks = mSpotifyService.getArtistTopTrack("test", "SE"); compareJSONWithoutNulls(body, tracks); }
Example #6
Source File: ParcelableModelsTest.java From spotify-web-api-android with MIT License | 4 votes |
ArrayList<Class<? extends Parcelable>> getModelClasses() { return Lists.newArrayList( Album.class, Albums.class, AlbumSimple.class, AlbumsPager.class, Artist.class, Artists.class, ArtistSimple.class, ArtistsPager.class, AudioFeaturesTrack.class, AudioFeaturesTracks.class, CategoriesPager.class, Category.class, Copyright.class, ErrorDetails.class, ErrorResponse.class, FeaturedPlaylists.class, Followers.class, Image.class, LinkedTrack.class, NewReleases.class, Playlist.class, PlaylistFollowPrivacy.class, PlaylistSimple.class, PlaylistsPager.class, PlaylistTrack.class, PlaylistTracksInformation.class, Recommendations.class, Result.class, Seed.class, SeedsGenres.class, SavedTrack.class, SnapshotId.class, Track.class, Tracks.class, TrackSimple.class, TracksPager.class, TrackToRemove.class, TrackToRemoveWithPosition.class, TracksToRemove.class, TracksToRemoveWithPosition.class, UserPrivate.class, UserPublic.class ); }
Example #7
Source File: ParcelableModelsTest.java From spotify-web-api-android with MIT License | 4 votes |
@Test public void tracksAreGoodParcelableCitizen() { String body = TestUtils.readTestData("tracks.json"); Tracks fixture = new GsonBuilder().create().fromJson(body, Tracks.class); testSingleParcelable(fixture); }
Example #8
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Spotify catalog information about an artist’s top tracks by country. * * @param artistId The Spotify ID for the artist. * @param country The country: an ISO 3166-1 alpha-2 country code. * @param callback Callback method * @see <a href="https://developer.spotify.com/web-api/get-artists-top-tracks/">Get an Artist’s Top Tracks</a> */ @GET("/artists/{id}/top-tracks") void getArtistTopTrack(@Path("id") String artistId, @Query("country") String country, Callback<Tracks> callback);
Example #9
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Spotify catalog information about an artist’s top tracks by country. * * @param artistId The Spotify ID for the artist. * @param country The country: an ISO 3166-1 alpha-2 country code. * @return An object whose key is "tracks" and whose value is an array of track objects. * @see <a href="https://developer.spotify.com/web-api/get-artists-top-tracks/">Get an Artist’s Top Tracks</a> */ @GET("/artists/{id}/top-tracks") Tracks getArtistTopTrack(@Path("id") String artistId, @Query("country") String country);
Example #10
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Several Tracks * * @param trackIds A comma-separated list of the Spotify IDs for the tracks * @param callback Callback method * @see <a href="https://developer.spotify.com/web-api/get-several-tracks/">Get Several Tracks</a> */ @GET("/tracks") void getTracks(@Query("ids") String trackIds, Callback<Tracks> callback);
Example #11
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Several Tracks * * @param trackIds A comma-separated list of the Spotify IDs for the tracks * @return An object whose key is "tracks" and whose value is an array of track objects. * @see <a href="https://developer.spotify.com/web-api/get-several-tracks/">Get Several Tracks</a> */ @GET("/tracks") Tracks getTracks(@Query("ids") String trackIds);
Example #12
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Several Tracks * * @param trackIds A comma-separated list of the Spotify IDs for the tracks * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-several-tracks/">endpoint documentation</a> * @param callback Callback method * @see <a href="https://developer.spotify.com/web-api/get-several-tracks/">Get Several Tracks</a> */ @GET("/tracks") void getTracks(@Query("ids") String trackIds, @QueryMap Map<String, Object> options, Callback<Tracks> callback);
Example #13
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get Several Tracks * * @param trackIds A comma-separated list of the Spotify IDs for the tracks * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-several-tracks/">endpoint documentation</a> * @return An object whose key is "tracks" and whose value is an array of track objects. * @see <a href="https://developer.spotify.com/web-api/get-several-tracks/">Get Several Tracks</a> */ @GET("/tracks") Tracks getTracks(@Query("ids") String trackIds, @QueryMap Map<String, Object> options);