kaaes.spotify.webapi.android.models.PlaylistSimple Java Examples
The following examples show how to use
kaaes.spotify.webapi.android.models.PlaylistSimple.
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 |
public void getFeatured(){ spotifyService.getFeaturedPlaylists(new SpotifyCallback<FeaturedPlaylists>() { @Override public void failure(SpotifyError spotifyError) { Log.d("SearchPager", spotifyError.toString()); } @Override public void success(FeaturedPlaylists featuredPlaylists, Response response) { List<PlaylistSimple> mlist = featuredPlaylists.playlists.items; for(PlaylistSimple simple : mlist) { Log.d("SearchPager Simple", simple.name); Log.d("SearchPager Simple", simple.images.get(0).url); ListManager.getInstance().addSimpleList(new SimplePlaylist(simple.name, simple.images.get(0).url)); } } }); }
Example #2
Source File: SearchPager.java From android-spotify-demo with MIT License | 6 votes |
public void getMyPlayList(){ Map<String, Object> options = new HashMap<>(); options.put(SpotifyService.LIMIT, 30); spotifyService.getMyPlaylists(options, new SpotifyCallback<Pager<PlaylistSimple>>() { @Override public void failure(SpotifyError spotifyError) { Log.d("SearchPager", spotifyError.toString()); } @Override public void success(Pager<PlaylistSimple> playlistSimplePager, Response response) { List<PlaylistSimple> simples = playlistSimplePager.items; for(PlaylistSimple simple : simples){ Log.d("SearchPager", simple.name); Log.d("SearchPager", simple.images.get(1).url); } } }); }
Example #3
Source File: Pasta.java From Pasta-for-Spotify with Apache License 2.0 | 6 votes |
@Nullable public ArrayList<PlaylistListData> searchPlaylists(String query, Map<String, Object> limitMap) throws InterruptedException { PlaylistsPager playlists = null; for (int i = 0; playlists == null && i < PreferenceUtils.getRetryCount(this); i++) { try { playlists = spotifyService.searchPlaylists(query, limitMap); } catch (Exception e) { e.printStackTrace(); if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200); else break; } } if (playlists == null) return null; ArrayList<PlaylistListData> playlistList = new ArrayList<>(); for (PlaylistSimple playlist : playlists.playlists.items) { playlistList.add(new PlaylistListData(playlist, me)); } return playlistList; }
Example #4
Source File: SpotifyServiceTest.java From spotify-web-api-android with MIT License | 5 votes |
@Test public void shouldGetCurrentUserPlaylists() throws Exception { final Type modelType = new TypeToken<Pager<PlaylistSimple>>() {}.getType(); String body = TestUtils.readTestData("user-playlists.json"); Pager<PlaylistSimple> fixture = mGson.fromJson(body, modelType); Response response = TestUtils.getResponseFromModel(fixture, modelType); when(mMockClient.execute(isA(Request.class))).thenReturn(response); Pager<PlaylistSimple> playlists = mSpotifyService.getMyPlaylists(); compareJSONWithoutNulls(body, playlists); }
Example #5
Source File: SpotifyServiceTest.java From spotify-web-api-android with MIT License | 5 votes |
@Test public void shouldGetUserPlaylists() throws Exception { final Type modelType = new TypeToken<Pager<PlaylistSimple>>() {}.getType(); String body = TestUtils.readTestData("user-playlists.json"); Pager<PlaylistSimple> fixture = mGson.fromJson(body, modelType); Response response = TestUtils.getResponseFromModel(fixture, modelType); when(mMockClient.execute(isA(Request.class))).thenReturn(response); Pager<PlaylistSimple> playlists = mSpotifyService.getPlaylists("test"); compareJSONWithoutNulls(body, playlists); }
Example #6
Source File: SpotifyServiceAndroidTest.java From spotify-web-api-android with MIT License | 5 votes |
@Test public void getMyPlaylist() throws Exception { Pager<PlaylistSimple> payload = mService.getMyPlaylists(); Request request = new Request.Builder() .get() .headers(mAuthHeader) .url("https://api.spotify.com/v1/me/playlists") .build(); Response response = mClient.newCall(request).execute(); assertEquals(200, response.code()); assertThat(payload, JsonEquals.jsonEquals(response.body().string())); }
Example #7
Source File: Pasta.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
@Nullable public Pager<PlaylistSimple> getMyPlaylists() throws InterruptedException { Pager<PlaylistSimple> playlists = null; for (int i = 0; playlists == null && i < PreferenceUtils.getRetryCount(this); i++) { try { playlists = spotifyService.getMyPlaylists(); } catch (Exception e) { e.printStackTrace(); if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200); else break; } } return playlists; }
Example #8
Source File: PlaylistListData.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
public PlaylistListData(PlaylistSimple playlist, UserPrivate me) { playlistName = playlist.name; playlistId = playlist.id; tracks = playlist.tracks.total; playlistOwnerName = playlist.owner.display_name; playlistOwnerId = playlist.owner.id; editable = playlist.owner.id.matches(me.id); if (editable) playlistPublic = playlist.is_public; try { playlistImage = playlist.images.get(playlist.images.size() / 2).url; } catch (IndexOutOfBoundsException e) { return; } playlistImageLarge = ""; int res = 0; for (Image image : playlist.images) { try { if (image.height * image.width > res) { playlistImageLarge = image.url; res = image.height * image.width; } } catch (NullPointerException ignored) { } } }
Example #9
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 #10
Source File: CategoryFragment.java From Pasta-for-Spotify with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_category, container, false); unbinder = ButterKnife.bind(this, rootView); pasta = (Pasta) getContext().getApplicationContext(); data = getArguments().getParcelable("category"); limitMap = new HashMap<>(); limitMap.put(SpotifyService.LIMIT, (PreferenceUtils.getLimit(getContext()) + 1) * 10); toolbar.setTitle(data.categoryName); toolbar.setNavigationIcon(R.drawable.ic_back); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().onBackPressed(); } }); int color = ContextCompat.getColor(getContext(), R.color.colorPrimary); setData(data.categoryName, color, color); spinner.setVisibility(View.VISIBLE); manager = new GridLayoutManager(getContext(), 1); recycler.setLayoutManager(manager); adapter = new ListAdapter(new ArrayList<ListData>()); recycler.setAdapter(adapter); recycler.setHasFixedSize(true); action = new Action<ArrayList<PlaylistListData>>() { @NonNull @Override public String id() { return "getCategoryPlaylists"; } @Nullable @Override protected ArrayList<PlaylistListData> run() throws InterruptedException { PlaylistsPager pager = null; for (int i = 0; pager == null && i < PreferenceUtils.getRetryCount(getContext()); i++) { try { pager = pasta.spotifyService.getPlaylistsForCategory(data.categoryId, limitMap); } catch (Exception e) { e.printStackTrace(); if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200); else break; } } if (pager == null) return null; ArrayList<PlaylistListData> list = new ArrayList<>(); for (PlaylistSimple playlist : pager.playlists.items) { list.add(new PlaylistListData(playlist, pasta.me)); } return list; } @Override protected void done(@Nullable ArrayList<PlaylistListData> result) { if (spinner != null) spinner.setVisibility(View.GONE); if (result == null) { pasta.onCriticalError(getActivity(), "category playlists action"); return; } adapter.setList(result); } }; action.execute(); return rootView; }
Example #11
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by the current Spotify user. * * @param callback Callback method. */ @GET("/me/playlists") void getMyPlaylists(Callback<Pager<PlaylistSimple>> callback);
Example #12
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by the current Spotify user. * * @return List of user's playlists wrapped in a {@code Pager} object */ @GET("/me/playlists") Pager<PlaylistSimple> getMyPlaylists();
Example #13
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by the current Spotify user. * * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-a-list-of-current-users-playlists/">endpoint documentation</a> * @param callback Callback method. */ @GET("/me/playlists") void getMyPlaylists(@QueryMap Map<String, Object> options, Callback<Pager<PlaylistSimple>> callback);
Example #14
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by the current Spotify user. * * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-a-list-of-current-users-playlists/">endpoint documentation</a> * @return List of user's playlists wrapped in a {@code Pager} object */ @GET("/me/playlists") Pager<PlaylistSimple> getMyPlaylists(@QueryMap Map<String, Object> options);
Example #15
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by a Spotify user. * * @param userId The user's Spotify user ID. * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">endpoint documentation</a> * @param callback Callback method * @see <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">Get a List of a User’s Playlists</a> */ @GET("/users/{id}/playlists") void getPlaylists(@Path("id") String userId, @QueryMap Map<String, Object> options, Callback<Pager<PlaylistSimple>> callback);
Example #16
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by a Spotify user. * * @param userId The user's Spotify user ID. * @param options Optional parameters. For list of supported parameters see * <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">endpoint documentation</a> * @return List of user's playlists wrapped in a {@code Pager} object * @see <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">Get a List of a User’s Playlists</a> */ @GET("/users/{id}/playlists") Pager<PlaylistSimple> getPlaylists(@Path("id") String userId, @QueryMap Map<String, Object> options);
Example #17
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by a Spotify user. * * @param userId The user's Spotify user ID. * @param callback Callback method * @see <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">Get a List of a User’s Playlists</a> */ @GET("/users/{id}/playlists") void getPlaylists(@Path("id") String userId, Callback<Pager<PlaylistSimple>> callback);
Example #18
Source File: SpotifyService.java From spotify-web-api-android with MIT License | 2 votes |
/** * Get a list of the playlists owned or followed by a Spotify user. * * @param userId The user's Spotify user ID. * @return List of user's playlists wrapped in a {@code Pager} object * @see <a href="https://developer.spotify.com/web-api/get-list-users-playlists/">Get a List of a User’s Playlists</a> */ @GET("/users/{id}/playlists") Pager<PlaylistSimple> getPlaylists(@Path("id") String userId);