kaaes.spotify.webapi.android.models.Artist Java Examples

The following examples show how to use kaaes.spotify.webapi.android.models.Artist. 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: SearchPager.java    From android-spotify-demo with MIT License 6 votes vote down vote up
public void getArtist(String id, final ArtistListener listener){

        spotifyService.getArtist(id, new SpotifyCallback<Artist>() {
            @Override
            public void failure(SpotifyError spotifyError) {
                Log.d("SearchPager", spotifyError.toString());
                listener.onError(spotifyError);
            }

            @Override
            public void success(Artist artist, Response response) {
                //Log.d("SearchPager CHECK", artist.images.get(0).url); // img url
                listener.onComplete(artist.images.get(1).url);
            }
        });
    }
 
Example #2
Source File: ArtistListData.java    From Pasta-for-Spotify with Apache License 2.0 6 votes vote down vote up
public ArtistListData(Artist artist) {
    artistName = artist.name;
    artistId = artist.id;

    if (artist.images.size() > 1) {
        artistImage = artist.images.get(1).url;
        artistImageLarge = artist.images.get(0).url;
    } else if (artist.images.size() > 0) {
        artistImage = artist.images.get(0).url;
        artistImageLarge = artist.images.get(0).url;
    } else {
        artistImage = "";
        artistImageLarge = "";
    }

    followers = artist.followers.total;
    genres = artist.genres;
}
 
Example #3
Source File: SearchPager.java    From android-spotify-demo with MIT License 5 votes vote down vote up
public void getMyTopArtist(final onCompleteTopArtistListener listener){

        Map<String, Object> options = new HashMap<>();
        options.put(SpotifyService.LIMIT, 10);

        final ListManager listManager = ListManager.getInstance();

        spotifyService.getTopArtists(options, new SpotifyCallback<Pager<Artist>>() {
            @Override
            public void failure(SpotifyError spotifyError) {
                Log.d("SearchPager", spotifyError.toString());

                if(listener != null)
                    listener.onError(spotifyError);
            }

            @Override
            public void success(Pager<Artist> artistPager, Response response) {
                List<Artist> mList = artistPager.items;

                for(Artist art : mList){
                    Log.d("SearchPager", art.name);
                    Log.d("SearchPager", art.images.get(1).url);

                    listManager.addTopArtist(new TopArtist(art.name, art.images.get(1).url));
                }

                if(listener != null)
                    listener.onComplete();
                else{
                    Log.d("SearchPager", "What is happening?");
                }
            }
        });
    }
 
Example #4
Source File: Pasta.java    From Pasta-for-Spotify with Apache License 2.0 5 votes vote down vote up
@Nullable
public ArtistListData getArtist(String id) throws InterruptedException {
    Artist a = null;
    for (int i = 0; a == null && i < PreferenceUtils.getRetryCount(this); i++) {
        try {
            a = spotifyService.getArtist(id);
        } catch (Exception e) {
            e.printStackTrace();
            if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200);
            else break;
        }
    }
    if (a == null) return null;
    return new ArtistListData(a);
}
 
Example #5
Source File: MainActivity.java    From android-web-api-sample with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Void... strings) {
    SpotifyApi api = new SpotifyApi();
    SpotifyService service = api.getService();

    ArtistsPager results = service.searchArtists("Paul");
    List<Artist> artists = results.artists.items;
    for (int i = 0; i < artists.size(); i++) {
        Artist artist = artists.get(i);
        Log.i(LOG_TAG, i + " " + artist.name);
    }
    return null;
}
 
Example #6
Source File: SpotifyServiceAndroidTest.java    From spotify-web-api-android with MIT License 5 votes vote down vote up
@Test
public void getArtist() throws Exception {
    Artist payload = mService.getArtist("54KCNI7URCrG6yjQK3Ukow");

    Request request = new Request.Builder()
            .get()
            .url("https://api.spotify.com/v1/artists/54KCNI7URCrG6yjQK3Ukow")
            .build();

    Response response = mClient.newCall(request).execute();
    assertEquals(200, response.code());

    assertThat(payload, JsonEquals.jsonEquals(response.body().string()));
}
 
Example #7
Source File: SpotifyServiceAndroidTest.java    From spotify-web-api-android with MIT License 5 votes vote down vote up
@Test
public void getUserTopArtists() throws Exception {
    Pager<Artist> payload = mService.getTopArtists();

    Request request = new Request.Builder()
            .get()
            .headers(mAuthHeader)
            .url("https://api.spotify.com/v1/me/top/artists")
            .build();

    Response response = mClient.newCall(request).execute();
    assertEquals(200, response.code());

    assertThat(payload, JsonEquals.jsonEquals(response.body().string()));
}
 
Example #8
Source File: SpotifyServiceTest.java    From spotify-web-api-android with MIT License 5 votes vote down vote up
@Test
public void shouldGetArtistData() throws IOException {
    String body = TestUtils.readTestData("artist.json");
    Artist fixture = mGson.fromJson(body, Artist.class);

    Response response = TestUtils.getResponseFromModel(fixture, Artist.class);
    when(mMockClient.execute(argThat(new MatchesId(fixture.id)))).thenReturn(response);

    Artist artist = mSpotifyService.getArtist(fixture.id);
    this.compareJSONWithoutNulls(body, artist);
}
 
Example #9
Source File: ParcelableModelsTest.java    From spotify-web-api-android with MIT License 4 votes vote down vote up
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 #10
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get Spotify catalog information for a single artist identified by their unique Spotify ID.
 *
 * @param artistId The Spotify ID for the artist.
 * @param callback Callback method
 * @see <a href="https://developer.spotify.com/web-api/get-artist/">Get an Artist</a>
 */
@GET("/artists/{id}")
void getArtist(@Path("id") String artistId, Callback<Artist> callback);
 
Example #11
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get Spotify catalog information for a single artist identified by their unique Spotify ID.
 *
 * @param artistId The Spotify ID for the artist.
 * @return Requested artist information
 * @see <a href="https://developer.spotify.com/web-api/get-artist/">Get an Artist</a>
 */
@GET("/artists/{id}")
Artist getArtist(@Path("id") String artistId);
 
Example #12
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get the current user’s top artists based on calculated affinity.
 *
 * @return The objects whose response body contains an artists or tracks object.
 * The object in turn contains a paging object of Artists or Tracks
 */
@GET("/me/top/artists")
Pager<Artist> getTopArtists();
 
Example #13
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get the current user’s top artists based on calculated affinity.
 *
 * @param callback callback method
 */
@GET("/me/top/artists")
void getTopArtists(Callback<Pager<Artist>> callback);
 
Example #14
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get the current user’s top artists based on calculated affinity.
 *
 * @param options Optional parameters. For list of available parameters see
 *                <a href="https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/">endpoint documentation</a>
 * @return The objects whose response body contains an artists or tracks object.
 * The object in turn contains a paging object of Artists or Tracks
 */
@GET("/me/top/artists")
Pager<Artist> getTopArtists(@QueryMap Map<String, Object> options);
 
Example #15
Source File: SpotifyService.java    From spotify-web-api-android with MIT License 2 votes vote down vote up
/**
 * Get the current user’s top artists based on calculated affinity.
 *
 * @param options  Optional parameters. For list of available parameters see
 *                 <a href="https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/">endpoint documentation</a>
 * @param callback Callback method
 */
@GET("/me/top/artists")
void getTopArtists(@QueryMap Map<String, Object> options, Callback<Pager<Artist>> callback);