Java Code Examples for com.google.android.gms.games.leaderboard.Leaderboards#LoadScoresResult
The following examples show how to use
com.google.android.gms.games.leaderboard.Leaderboards#LoadScoresResult .
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: ScoresLoadedListener.java From ANE-Google-Play-Game-Services with Apache License 2.0 | 5 votes |
public void onResult( Leaderboards.LoadScoresResult scoresResult ) { LeaderboardScoreBuffer scores = scoresResult.getScores(); if( scores.getCount() == currentBufferSize ) { Extension.context.onLeaderboardLoaded(scores); } else { currentBufferSize = scores.getCount(); Games.Leaderboards.loadMoreScores( Extension.context.getApiClient(), scores, 25, PageDirection.NEXT ).setResultCallback( this ); } }
Example 2
Source File: GpgsClient.java From gdx-gamesvcs with Apache License 2.0 | 4 votes |
private boolean fetchLeaderboardEntriesSync(String leaderBoardId, int limit, boolean relatedToPlayer, IFetchLeaderBoardEntriesResponseListener callback) { if (!isSessionActive()) return false; if (gpgsLeaderboardIdMapper != null) leaderBoardId = gpgsLeaderboardIdMapper.mapToGsId(leaderBoardId); Leaderboards.LoadScoresResult scoresResult = (relatedToPlayer ? Games.Leaderboards.loadPlayerCenteredScores(mGoogleApiClient, leaderBoardId, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, MathUtils.clamp(limit, 1, 25), forceRefresh).await() : Games.Leaderboards.loadTopScores(mGoogleApiClient, leaderBoardId, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, MathUtils.clamp(limit, 1, 25), forceRefresh).await()); if (!scoresResult.getStatus().isSuccess()) { Gdx.app.log(GAMESERVICE_ID, "Failed to fetch leaderboard entries:" + scoresResult.getStatus().getStatusMessage()); callback.onLeaderBoardResponse(null); return false; } LeaderboardScoreBuffer scores = scoresResult.getScores(); Array<ILeaderBoardEntry> gpgsLbEs = new Array<ILeaderBoardEntry>(scores.getCount()); String playerDisplayName = getPlayerDisplayName(); for (LeaderboardScore score : scores) { GpgsLeaderBoardEntry gpgsLbE = new GpgsLeaderBoardEntry(); gpgsLbE.userDisplayName = score.getScoreHolderDisplayName(); gpgsLbE.currentPlayer = gpgsLbE.userDisplayName.equalsIgnoreCase(playerDisplayName); gpgsLbE.formattedValue = score.getDisplayScore(); gpgsLbE.scoreRank = score.getDisplayRank(); gpgsLbE.userId = score.getScoreHolder().getPlayerId(); gpgsLbE.sortValue = score.getRawScore(); gpgsLbE.scoreTag = score.getScoreTag(); gpgsLbEs.add(gpgsLbE); } scores.release(); callback.onLeaderBoardResponse(gpgsLbEs); return true; }