kaaes.spotify.webapi.android.SpotifyService Java Examples
The following examples show how to use
kaaes.spotify.webapi.android.SpotifyService.
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 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 #2
Source File: SearchPager.java From spotify-web-api-android with MIT License | 6 votes |
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); } }); }
Example #3
Source File: SearchPager.java From android-spotify-demo with MIT License | 5 votes |
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: SearchPager.java From android-spotify-demo with MIT License | 5 votes |
public void getMyTopTracks(final onCompleteTopTrackListener listener){ Map<String, Object> options = new HashMap<>(); options.put(SpotifyService.LIMIT, 10); final ListManager listManager = ListManager.getInstance(); spotifyService.getTopTracks(options, new SpotifyCallback<Pager<Track>>() { @Override public void failure(SpotifyError spotifyError) { Log.d("SearchPager", spotifyError.toString()); if(listener != null) listener.onError(spotifyError); } @Override public void success(Pager<Track> trackPager, Response response) { List<Track> tracks = trackPager.items; for(Track track : tracks){ Log.d("SearchPager", track.album.name); Log.d("SearchPager", track.album.images.get(1).url); listManager.addTopTrack(new TopTrack(track.album.name, track.album.images.get(1).url)); } if(listener != null) listener.onComplete(); } }); }
Example #5
Source File: SpotifyManagerImpl.java From mirror with Apache License 2.0 | 5 votes |
private SpotifyService createSpotifyService(String accessToken) { return new RestAdapter.Builder() .setEndpoint(SpotifyApi.SPOTIFY_WEB_API_ENDPOINT) .setRequestInterceptor(r -> r.addHeader("Authorization", "Bearer " + accessToken)) .build() .create(SpotifyService.class); }
Example #6
Source File: MainActivity.java From android-web-api-sample with Apache License 2.0 | 5 votes |
@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 #7
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 #8
Source File: SearchPager.java From spotify-web-api-android with MIT License | 4 votes |
public SearchPager(SpotifyService spotifyApi) { mSpotifyApi = spotifyApi; }