当前位置: 首页>>代码示例>>Java>>正文


Java SpotifyService类代码示例

本文整理汇总了Java中kaaes.spotify.webapi.android.SpotifyService的典型用法代码示例。如果您正苦于以下问题:Java SpotifyService类的具体用法?Java SpotifyService怎么用?Java SpotifyService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpotifyService类属于kaaes.spotify.webapi.android包,在下文中一共展示了SpotifyService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserPlaylists

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private Observable<Pager<PlaylistSimple>> getUserPlaylists() {
    return Observable.create(subscriber -> {
        Map<String, Object> searchOptions = new HashMap<>();
        searchOptions.put(SpotifyService.LIMIT, SpotifyConstants.PLAYLIST_SEARCH_QUERY_RESPONSE_LIMIT);
        searchOptions.put(SpotifyService.OFFSET, 0);

        findPlaylistsRecursively(searchOptions)
            .subscribeOn(Schedulers.io())
            .retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS))
            .subscribe(playlistPager -> {
                subscriber.onNext(playlistPager);
            }, throwable -> {
                Log.d(LogTag.LOG_SEARCH, "Error when getting playlist data");
            });
    });
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:17,代码来源:PlaylistSearchPresenter.java

示例2: loadFeaturedPlaylists

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private void loadFeaturedPlaylists() {
    Map<String, Object> options = new HashMap<>();
    options.put(SpotifyService.COUNTRY, SpotifyTvApplication.getCurrentUserCountry());
    options.put("timestamp", DateFormat.format("yyyy-MM-dd'T'hh:mm:ss", new Date()));
    getSpotifyService().getFeaturedPlaylists(options, new Callback<FeaturedPlaylists>() {
        @Override
        public void success(FeaturedPlaylists featuredPlaylists, Response response) {
            mFeaturedPlaylistsAdapter.addAll(0, featuredPlaylists.playlists.items);
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:17,代码来源:MainFragment.java

示例3: loadPlaylists

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private void loadPlaylists(int offset) {
    if (mPlaylistsLoading){
        return;
    }

    mPlaylistsLoading = true;
    Map<String, Object> options = new HashMap<>();
    options.put(SpotifyService.OFFSET, offset);
    options.put(SpotifyService.LIMIT, Constants.PAGE_LIMIT);
    getSpotifyService().getMyPlaylists(options, new Callback<Pager<PlaylistSimple>>() {
        @Override
        public void success(Pager<PlaylistSimple> playlistPager, Response response) {
            mPlaylistsAdapter.addAll(playlistPager.total, mPlaylistsAdapter.size(), playlistPager.items);
            mPlaylistsLoading = false;
        }

        @Override
        public void failure(RetrofitError error) {
            mPlaylistsLoading = false;
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:23,代码来源:MainFragment.java

示例4: loadMySongs

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private void loadMySongs(int offset) {
    if (mMySongsLoading){
        return;
    }

    mMySongsLoading = true;
    Map<String, Object> options = new HashMap<>();
    options.put(SpotifyService.OFFSET, offset);
    options.put(SpotifyService.LIMIT, Constants.PAGE_LIMIT);
    getSpotifyService().getMySavedTracks(options, new Callback<Pager<SavedTrack>>() {
        @Override
        public void success(Pager<SavedTrack> savedTrackPager, Response response) {
            List<Track> tracks = new ArrayList<>(savedTrackPager.items.size());
            for (SavedTrack savedTrack : savedTrackPager.items) {
                tracks.add(savedTrack.track);
            }
            mSavedSongsAdapter.addAll(savedTrackPager.total, mSavedSongsAdapter.size(), tracks);
            mMySongsLoading = false;
        }

        @Override
        public void failure(RetrofitError error) {
            mMySongsLoading = false;
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:27,代码来源:MainFragment.java

示例5: loadAlbumFromUri

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private static void loadAlbumFromUri(SpotifyService service, String uri, final SpotifyObjectLoaderCallback callback) {
    SpotifyTvApplication.getInstance().getSpotifyService().getAlbum(uri.replace(ALBUM_URI, ""), new Callback<Album>() {
        @Override
        public void success(Album album, Response response) {
            if (callback != null) {
                callback.success(album, response);
            }
        }

        @Override
        public void failure(RetrofitError error) {
            if (callback != null) {
                callback.failure(error);
            }
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:18,代码来源:SpotifyUriLoader.java

示例6: loadArtistFromUri

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private static void loadArtistFromUri(SpotifyService service, String uri, final SpotifyObjectLoaderCallback callback) {
    SpotifyTvApplication.getInstance().getSpotifyService().getArtist(uri.replace(ARTIST_URI, ""), new Callback<Artist>() {
        @Override
        public void success(Artist artist, Response response) {
            if (callback != null) {
                callback.success(artist, response);
            }
        }

        @Override
        public void failure(RetrofitError error) {
            if (callback != null) {
                callback.failure(error);
            }
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:18,代码来源:SpotifyUriLoader.java

示例7: loadPlaylistFromUri

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private static void loadPlaylistFromUri(SpotifyService service, String uri, final SpotifyObjectLoaderCallback callback) {
    String[] uriParts = uri.split(USER_PLAYLIST_URI);
    if (uriParts.length == 2) {
        String userId = uriParts[0].replace(USER_URI, "");
        String playlistId = uriParts[1];
        SpotifyTvApplication.getInstance().getSpotifyService().getPlaylist(userId, playlistId, new Callback<Playlist>() {
            @Override
            public void success(Playlist playlist, Response response) {
                if (callback != null) {
                    callback.success(playlist, response);
                }
            }

            @Override
            public void failure(RetrofitError error) {
                if (callback != null) {
                    callback.failure(error);
                }
            }
        });
    }
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:23,代码来源:SpotifyUriLoader.java

示例8: loadTrackFromUri

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private static void loadTrackFromUri(SpotifyService service, String uri, final SpotifyObjectLoaderCallback callback) {
    SpotifyTvApplication.getInstance().getSpotifyService().getTrack(uri.replace(TRACK_URI, ""), new Callback<Track>() {
        @Override
        public void success(Track track, Response response) {
            if (callback != null) {
                callback.success(track, response);
            }
        }

        @Override
        public void failure(RetrofitError error) {
            if (callback != null) {
                callback.failure(error);
            }
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:18,代码来源:SpotifyUriLoader.java

示例9: SpotifyPlayerController

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
public SpotifyPlayerController(Player player, SpotifyService spotifyService) {
    context = SpotifyTvApplication.getInstance().getApplicationContext();
    mHandler = new Handler(context.getMainLooper());
    mUserPreferences = UserPreferences.getInstance(context);

    audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    mPlayer = player;

    mPlayer.addPlayerNotificationCallback(this);
    mPlayer.addConnectionStateCallback(this);
    setPlayerBitrate(mUserPreferences.getBitrate());
    setShuffle(mUserPreferences.getShuffle());

    mediaSessionController = new MediaPlayerSessionController(context, this);

    mSpotifyService = spotifyService;

    // init playing state with dummy data
    resetPlayingState();
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:21,代码来源:SpotifyPlayerController.java

示例10: doInBackground

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
@Override
protected AsyncTaskResult<List<Track>> doInBackground(Artist... params) {
    try {
        Map<String, Object> options = new HashMap<>();
        options.put(SpotifyService.COUNTRY, Locale.getDefault().getCountry());
        Tracks artistTopTracks = new SpotifyApi().getService().getArtistTopTrack(params[0].getId(), options);

        List<Track> trackList = new ArrayList<>();
        for(kaaes.spotify.webapi.android.models.Track track : artistTopTracks.tracks) {
            trackList.add(new Track(track));
        }

        return new AsyncTaskResult<>(trackList);

    } catch (RetrofitError error) {
        if(error.getResponse() == null) {
            return new AsyncTaskResult<>(new NotFoundException());
        } else {
            switch(error.getResponse().getStatus()) {
                case HttpURLConnection.HTTP_BAD_REQUEST:
                    return new AsyncTaskResult<>(new BadRequestException());
                case HttpURLConnection.HTTP_NOT_FOUND:
                    return new AsyncTaskResult<>(new NotFoundException());
                default:
                    return new AsyncTaskResult<>(error);
            }
        }
    }
}
 
开发者ID:tassioauad,项目名称:SpotifyStreamer,代码行数:30,代码来源:TrackListTopByArtistAsyncTask.java

示例11: onCreate

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    songPreviewPlayer = new PreviewPlayer();

    //load user data and user search suggestions
    restartableLatestCache(LOAD_USER_RESTARTABLE_ID,
        () -> spotifyRepository.getMe(spotifyCommunicatorService.getWebApi())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS)),
        (songSearchView, userPrivate) -> {
            user = new User(userPrivate.id, userPrivate.display_name, userPrivate.images);
            //load personalized search suggestions
            Map<String, Object> searchOptions = new HashMap<>();
            searchOptions.put(SpotifyService.LIMIT, SpotifyConstants.TOP_TRACKS_QUERY_RESPONSE_LIMIT);
            searchOptions.put(SpotifyService.TIME_RANGE, SpotifyConstants.TIME_RANGE_SHORT);
            spotifyRepository.getMyTopTracks(searchOptions, spotifyCommunicatorService.getWebApi())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS))
                .subscribe(tracks -> {
                    List<Song> songSuggestions = TrackMapper.tracksToSongs(tracks, user);
                    SongSearchSuggestionsBuilder suggestionsBuilder =
                        new SongSearchSuggestionsBuilder(songSuggestions, ApplicationConstants.MAX_SONG_SUGGESTIONS);
                    songSearchView.updateSearchSuggestions(suggestionsBuilder);
                });
        },
        (songSearchView, throwable) -> {
            Log.d(LogTag.LOG_SEARCH, "Error when getting user Spotify data");
        });

    if (savedState == null) {
        start(LOAD_USER_RESTARTABLE_ID);
    }
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:38,代码来源:SongSearchPresenter.java

示例12: searchTracks

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
void searchTracks(String query) {
    Map<String, Object> searchOptions = new HashMap<>();
    searchOptions.put(SpotifyService.LIMIT, SpotifyConstants.TRACK_SEARCH_QUERY_RESPONSE_LIMIT);
    searchOptions.put(SpotifyService.OFFSET, 0);

    partiesRepository.getParty(partyTitle)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(partySnapshot -> {
            Party dbParty = partySnapshot.child(FirebaseConstants.CHILD_PARTYINFO).getValue(Party.class);
            searchOptions.put(SpotifyService.MARKET, dbParty.getHostMarket());

            searchTracksRecursively(query, searchOptions)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(tracksPager -> TrackMapper.tracksToSongs(tracksPager.tracks.items, user))
                .subscribe(songs -> {
                    if (getView() != null) {
                        if (songs.isEmpty()) getView().showMessage("No songs were found for the search query " + query);
                        getView().updateSearch(songs);
                    }
                }, throwable -> {
                    Log.d(LogTag.LOG_SEARCH, "Something went wrong on searching for tracks");
                    throwable.printStackTrace();
                });
        });
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:28,代码来源:SongSearchPresenter.java

示例13: searchTracksRecursively

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private Observable<TracksPager> searchTracksRecursively(String query, Map<String, Object> searchOptions) {
    int lastOffset = (int) searchOptions.get(SpotifyService.OFFSET);
    return spotifyRepository.searchTracks(query, searchOptions, spotifyCommunicatorService.getWebApi())
        .concatMap(tracksPager -> {
            if (lastOffset + tracksPager.tracks.limit >= SpotifyConstants.TRACK_SEARCH_TOTAL_ITEMS_LIMIT
                || lastOffset + tracksPager.tracks.limit >= tracksPager.tracks.total) {
                return Observable.just(tracksPager);
            }
            else {
                searchOptions.put(SpotifyService.OFFSET, lastOffset + tracksPager.tracks.limit);
                return Observable.just(tracksPager).concatWith(searchTracksRecursively(query, searchOptions));
            }
        })
        .doOnError(throwable -> Log.d(LogTag.LOG_SEARCH, "Something went wrong on tracks search recursion: " + throwable.getMessage()));
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:16,代码来源:SongSearchPresenter.java

示例14: loadPlaylistSongs

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
void loadPlaylistSongs(PlaylistSimple playlist) {
    Map<String, Object> searchOptions = new HashMap<>();
    searchOptions.put(SpotifyService.LIMIT, SpotifyConstants.PLAYLIST_TRACK_SEARCH_QUERY_RESPONSE_LIMIT);
    searchOptions.put(SpotifyService.OFFSET, 0);

    partiesRepository.getParty(partyTitle)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(partySnapshot -> {
            Party dbParty = partySnapshot.child(FirebaseConstants.CHILD_PARTYINFO).getValue(Party.class);
            searchOptions.put(SpotifyService.MARKET, dbParty.getHostMarket());

            findPlaylistTracksRecursively(playlist, searchOptions)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                //filter out local and unplayable tracks
                .map(playlistPager -> {
                    List<PlaylistTrack> filteredTracks = new ArrayList<>();
                    filteredTracks.addAll(playlistPager.items);
                    for (PlaylistTrack playlistTrack : playlistPager.items) {
                        if (playlistTrack.is_local || !playlistTrack.track.is_playable) {
                            filteredTracks.remove(playlistTrack);
                        }
                    }
                    return filteredTracks;
                })
                .map(filteredTracks -> TrackMapper.playlistTracksToSongs(filteredTracks, user))
                .subscribe(songs -> {
                    if (getView() != null) {
                        if (songs.isEmpty()) getView().showMessage("Playlist is empty");
                        getView().updateSongs(songs);
                    }
                }, throwable -> {
                    Log.d(LogTag.LOG_SEARCH, "Something went wrong on loading playlist songs");
                    throwable.printStackTrace();
                });
        });
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:39,代码来源:PlaylistSearchPresenter.java

示例15: findPlaylistsRecursively

import kaaes.spotify.webapi.android.SpotifyService; //导入依赖的package包/类
private Observable<Pager<PlaylistSimple>> findPlaylistsRecursively(Map<String, Object> searchOptions) {
    int lastOffset = (int) searchOptions.get(SpotifyService.OFFSET);
    return spotifyRepository.getMyPlaylists(searchOptions, spotifyCommunicatorService.getWebApi())
        .concatMap(playlistPager -> {
            if (lastOffset + playlistPager.limit >= SpotifyConstants.PLAYLIST_SEARCH_TOTAL_ITEMS_LIMIT
                || lastOffset + playlistPager.limit >= playlistPager.total) {
                return Observable.just(playlistPager);
            }
            else {
                searchOptions.put(SpotifyService.OFFSET, lastOffset + playlistPager.limit);
                return Observable.just(playlistPager).concatWith(findPlaylistsRecursively(searchOptions));
            }
        })
        .doOnError(throwable -> Log.d(LogTag.LOG_SEARCH, "Something went wrong on playlist recursion: " + throwable.getMessage()));
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:16,代码来源:PlaylistSearchPresenter.java


注:本文中的kaaes.spotify.webapi.android.SpotifyService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。