Java源码示例:kaaes.spotify.webapi.android.models.TracksPager
示例1
private void getData(String query, int offset, final int limit, final CompleteListener listener) {
Map<String, Object> options = new HashMap<>();
options.put(SpotifyService.OFFSET, offset);
options.put(SpotifyService.LIMIT, limit);
mSpotifyApi.searchTracks(query, options, new SpotifyCallback<TracksPager>() {
@Override
public void success(TracksPager tracksPager, Response response) {
listener.onComplete(tracksPager.tracks.items);
}
@Override
public void failure(SpotifyError error) {
listener.onError(error);
}
});
}
示例2
private void getData(String query, final CompleteListener listener){
spotifyService.searchTracks(query, new SpotifyCallback<TracksPager>() {
@Override
public void failure(SpotifyError spotifyError) {
listener.onError(spotifyError);
}
@Override
public void success(TracksPager tracksPager, Response response) {
listener.onComplete(tracksPager.tracks.items);
}
});
}
示例3
@Test
public void shouldGetSearchedTracks() throws IOException {
String body = TestUtils.readTestData("search-track.json");
TracksPager fixture = mGson.fromJson(body, TracksPager.class);
Response response = TestUtils.getResponseFromModel(fixture, TracksPager.class);
when(mMockClient.execute(isA(Request.class))).thenReturn(response);
TracksPager tracks = mSpotifyService.searchTracks("Christmas");
compareJSONWithoutNulls(body, tracks);
}
示例4
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
);
}
示例5
/**
* Get Spotify catalog information about tracks that match a keyword string.
*
* @param q The search query's keywords (and optional field filters and operators), for example "roadhouse+blues"
* @param callback Callback method.
* @see <a href="https://developer.spotify.com/web-api/search-item/">Search for an Item</a>
*/
@GET("/search?type=track")
void searchTracks(@Query("q") String q, Callback<TracksPager> callback);
示例6
/**
* Get Spotify catalog information about tracks that match a keyword string.
*
* @param q The search query's keywords (and optional field filters and operators), for example "roadhouse+blues"
* @return A paginated list of results
* @see <a href="https://developer.spotify.com/web-api/search-item/">Search for an Item</a>
*/
@GET("/search?type=track")
TracksPager searchTracks(@Query("q") String q);
示例7
/**
* Get Spotify catalog information about tracks that match a keyword string.
*
* @param q The search query's keywords (and optional field filters and operators), for example "roadhouse+blues"
* @param options Optional parameters. For list of supported parameters see
* <a href="https://developer.spotify.com/web-api/search-item/">endpoint documentation</a>
* @param callback Callback method.
* @see <a href="https://developer.spotify.com/web-api/search-item/">Search for an Item</a>
*/
@GET("/search?type=track")
void searchTracks(@Query("q") String q, @QueryMap Map<String, Object> options, Callback<TracksPager> callback);
示例8
/**
* Get Spotify catalog information about tracks that match a keyword string.
*
* @param q The search query's keywords (and optional field filters and operators), for example "roadhouse+blues"
* @param options Optional parameters. For list of supported parameters see
* <a href="https://developer.spotify.com/web-api/search-item/">endpoint documentation</a>
* @return A paginated list of results
* @see <a href="https://developer.spotify.com/web-api/search-item/">Search for an Item</a>
*/
@GET("/search?type=track")
TracksPager searchTracks(@Query("q") String q, @QueryMap Map<String, Object> options);