• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Pager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTracks

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
@Nullable
public ArrayList<TrackListData> getTracks(AlbumListData data) throws InterruptedException {
    Pager<TrackSimple> tracks = null;
    for (int i = 0; tracks == null && i < PreferenceUtils.getRetryCount(this); i++) {
        try {
            tracks = spotifyService.getAlbum(data.albumId).tracks;
        } catch (Exception e) {
            e.printStackTrace();
            if (StaticUtils.shouldResendRequest(e)) Thread.sleep(200);
            else break;
        }
    }
    if (tracks == null) return null;

    ArrayList<TrackListData> trackList = new ArrayList<>();
    for (TrackSimple track : tracks.items) {
        trackList.add(new TrackListData(track, data.albumName, data.albumId, data.albumImage, data.albumImageLarge));
    }
    return trackList;
}
 
开发者ID:TheAndroidMaster,项目名称:Pasta-for-Spotify,代码行数:21,代码来源:Pasta.java


示例2: getUserPlaylists

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的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


示例3: loadPlaylists

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的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.models.Pager; //导入依赖的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: getMyPlaylists

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
@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;
}
 
开发者ID:TheAndroidMaster,项目名称:Pasta-for-Spotify,代码行数:15,代码来源:Pasta.java


示例6: findPlaylistsRecursively

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的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


示例7: findPlaylistTracksRecursively

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


示例8: getMyTopTracks

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
public Observable<List<Track>> getMyTopTracks(Map<String, Object> searchOptions, SpotifyService spotifyService) {
    return Observable.create(subscriber -> spotifyService.getTopTracks(searchOptions, new Callback<Pager<Track>>() {
        @Override
        public void success(Pager<Track> trackPager, Response response) {
            subscriber.onNext(trackPager.items);
            subscriber.onComplete();
        }

        @Override
        public void failure(RetrofitError error) {
            subscriber.onError(error);
        }
    }));
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:15,代码来源:SpotifyRepository.java


示例9: getMyPlaylists

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
public Observable<Pager<PlaylistSimple>> getMyPlaylists(Map<String, Object> searchOptions, SpotifyService spotifyService) {
    return Observable.create(subscriber -> spotifyService.getMyPlaylists(searchOptions, new Callback<Pager<PlaylistSimple>>() {
        @Override
        public void success(Pager<PlaylistSimple> playlistSimplePager, Response response) {
            subscriber.onNext(playlistSimplePager);
            subscriber.onComplete();
        }

        @Override
        public void failure(RetrofitError error) {
            subscriber.onError(error);
        }
    }));
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:15,代码来源:SpotifyRepository.java


示例10: getPlaylistTracks

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
public Observable<Pager<PlaylistTrack>> getPlaylistTracks(String userId, String playlistId, Map<String, Object> searchOptions, SpotifyService spotifyService) {
    return Observable.create(subscriber -> spotifyService.getPlaylistTracks(userId, playlistId, searchOptions, new Callback<Pager<PlaylistTrack>>() {
        @Override
        public void success(Pager<PlaylistTrack> playlistTrackPager, Response response) {
            subscriber.onNext(playlistTrackPager);
            subscriber.onComplete();
        }

        @Override
        public void failure(RetrofitError error) {
            subscriber.onError(error);
        }
    }));
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:15,代码来源:SpotifyRepository.java


示例11: getSpotifyArtists

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
/**
 * Returns a list of the Spotify artists whose names match a supplied string.
 * @param strSearch the string to match against
 * @return a list of the Spotify artists whose names match the search string
 */
private List<Artist> getSpotifyArtists(String strSearch) {
    try {
        ArtistsPager artistsPager = getSpotifyService().searchArtists(strSearch);
        if (artistsPager != null) {
            Pager<Artist> artistPager = artistsPager.artists;
            if (artistPager != null) {
                return artistPager.items;
            }
        }
    } catch (RetrofitError e) {
        Log.e(LOG_TAG, "RetrofitError while fetching artist list: " + e);
    }
    return null;
}
 
开发者ID:edmundjohnson,项目名称:nd-spotify,代码行数:20,代码来源:ArtistListFragment.java


示例12: loadAlbums

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
private void loadAlbums(final int offset) {

        HashMap<String, Object> options = new HashMap<>();
        options.put(SpotifyService.OFFSET, Integer.toString(offset));
        options.put(SpotifyService.LIMIT, Integer.toString(Constants.PAGE_LIMIT));
        options.put(SpotifyService.MARKET, SpotifyTvApplication.getCurrentUserCountry());
        SpotifyTvApplication.getInstance().getSpotifyService().getArtistAlbums(mArtistId, options, new Callback<Pager<Album>>() {
            @Override
            public void success(Pager<Album> albumPager, Response response) {
                for (Album album : albumPager.items) {
                    try {
                        AlbumType albumType = AlbumType.valueOf(album.album_type.toUpperCase());

                        // add to corresponding adapter
                        ArrayObjectAdapter adapter = mAlbumsAdapters.get(albumType);
                        adapter.add(adapter.size(), album);
                    } catch (IllegalArgumentException e) {
                        Log.d(TAG, String.format("Album Type %s is unknown", album.album_type), e);
                    }
                }

                if (albumPager.next != null) {
                    loadAlbums(albumPager.offset + Constants.PAGE_LIMIT);
                }
            }

            @Override
            public void failure(RetrofitError error) {

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


示例13: loadMyAlbums

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
private void loadMyAlbums(final int offset) {
    if (mMyAlbumsLoading){
        return;
    }

    mMyAlbumsLoading = true;
    Map<String, Object> options = new HashMap<>();
    options.put(SpotifyService.OFFSET, offset);
    options.put(SpotifyService.LIMIT, Constants.PAGE_LIMIT);
    getSpotifyService().getMySavedAlbums(options, new Callback<Pager<SavedAlbum>>() {
        @Override
        public void success(Pager<SavedAlbum> savedAlbumPager, Response response) {
            List<Album> albums = new ArrayList<>(savedAlbumPager.items.size());
            List<ArtistSimple> artists = new ArrayList<>(savedAlbumPager.items.size());

            // keep track of all artists to avoid duplicates
            if (offset == 0) {
                allArtistUris = new ArrayList<>(savedAlbumPager.items.size());
            }

            for (SavedAlbum savedAlbum : savedAlbumPager.items) {
                albums.add(savedAlbum.album);
                for (ArtistSimple artist : savedAlbum.album.artists) {
                    if (!allArtistUris.contains(artist.id)) {
                        artists.add(artist);
                        allArtistUris.add(artist.id);
                    }
                }
            }
            mSavedAlbumsAdapter.addAll(savedAlbumPager.total, mSavedAlbumsAdapter.size(), albums);
            mSavedArtistsAdapter.addAll(mSavedArtistsAdapter.size(), artists);
            mMyAlbumsLoading = false;
        }

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


示例14: getTrackUrisFromTrackPager

import kaaes.spotify.webapi.android.models.Pager; //导入依赖的package包/类
public static List<String> getTrackUrisFromTrackPager(Pager<TrackSimple> trackPager) {
    List<String> trackUris = new ArrayList<>(trackPager.items.size());
    for (TrackSimple trackSimple : trackPager.items) {
        trackUris.add(trackSimple.uri);
    }
    return trackUris;
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:8,代码来源:Utils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnonId类代码示例发布时间:2022-05-22
下一篇:
Java SendDocument类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap