本文整理汇总了Java中com.google.android.gms.games.leaderboard.Leaderboards类的典型用法代码示例。如果您正苦于以下问题:Java Leaderboards类的具体用法?Java Leaderboards怎么用?Java Leaderboards使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Leaderboards类属于com.google.android.gms.games.leaderboard包,在下文中一共展示了Leaderboards类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: z
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
public Leaderboards.LoadScoresResult z(final Status paramStatus)
{
return new Leaderboards.LoadScoresResult()
{
public Leaderboard getLeaderboard()
{
return null;
}
public LeaderboardScoreBuffer getScores()
{
return new LeaderboardScoreBuffer(DataHolder.empty(14));
}
public Status getStatus()
{
return paramStatus;
}
public void release()
{
}
};
}
示例2: leaderboard_submit_score_immediate
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
/**
* Submit a given score to the specified leaderboard immediately
* with a callback result
* @param id leaderboard id obtained from your Developer Console
* @param score score number the player earned
*
* Usage:
* const ST_OK = "STATUS_OK"
* var leaderboard_id = "exampleLeaderbord123ID"
*
* ...
*
* gpgs.leaderboard_submit_score_immediate(leaderboard_id, 9001)
*
* ...
*
* func _on_leaderboard_score_submitted(id, score, status):
* if status == ST_OK:
* //succeeded action
* else:
* //failed action
*/
public void leaderboard_submit_score_immediate(final String id, final int score) {
logMethod();
if (!isConnectedLogged()) return;
final boolean debug = this.debug;
leaderboards.submitScoreImmediate(
id, score, new ResultCallback<Leaderboards.SubmitScoreResult>() {
@Override
public void onResult(@NonNull Leaderboards.SubmitScoreResult submitScoreResult) {
String status = extractStatusNameFromStatus(
submitScoreResult.getStatus().toString());
if (debug) Log.d(TAG, MODULE
+ ": > tried to submit score value " + String.valueOf(score)
+ " with " + status);
GodotLib.calldeferred(
instance_id, "_on_leaderboard_score_submitted",
new Object[] { id, score, status });
}
});
}
示例3: incrementScore
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override public IFuture<Boolean> incrementScore(final String leaderboardId, final int by) {
final Future<Boolean> future = Future.make();
activity.getMainHandler().post(new Runnable() {
@Override public void run() {
Games.Leaderboards
.loadCurrentPlayerLeaderboardScore(
helper.getApiClient(),
leaderboardId,
LeaderboardVariant.TIME_SPAN_WEEKLY,
LeaderboardVariant.COLLECTION_PUBLIC
)
.setResultCallback(new ResultCallback<LoadPlayerScoreResult>() {
@Override public void onResult(LoadPlayerScoreResult result) {
processLoadScoreResult(result, leaderboardId, by, future);
}
});
}
});
return future;
}
示例4: onUpdateScoreClick
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@ィ(ˊ="USER_RECEIVED")
public void onUpdateScoreClick(JSONObject paramJSONObject)
{
if (paramJSONObject != null)
{
QuizApplication.ᐝ().ˋ(paramJSONObject);
int i = QuizApplication.ᐝ().ˋ.ʻ().ˊ;
if (i > 0)
{
Leaderboards localLeaderboards = Games.Leaderboards;
כּ localכּ = this.mHelper;
if (localכּ.ˎ == null)
throw new IllegalStateException("No GoogleApiClient. Did you call setup()?");
localLeaderboards.submitScore(localכּ.ˎ, getResources().getString(2131165269), i);
}
}
}
示例5: x
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
public Leaderboards.LeaderboardMetadataResult x(final Status paramStatus)
{
return new Leaderboards.LeaderboardMetadataResult()
{
public LeaderboardBuffer getLeaderboards()
{
return new LeaderboardBuffer(DataHolder.empty(14));
}
public Status getStatus()
{
return paramStatus;
}
public void release()
{
}
};
}
示例6: A
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
public Leaderboards.SubmitScoreResult A(final Status paramStatus)
{
return new Leaderboards.SubmitScoreResult()
{
public ScoreSubmissionData getScoreData()
{
return new ScoreSubmissionData(DataHolder.empty(14));
}
public Status getStatus()
{
return paramStatus;
}
public void release()
{
}
};
}
示例7: uploadLeaderBoard
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@ィ(ˊ="GAME_SERVICES_UPLOAD_LEADER_BOARD")
public final void uploadLeaderBoard(כּ paramכּ)
{
if (paramכּ.ˎ != null)
paramכּ.ˎ.isConnected();
int i;
if ((paramכּ.ˎ != null) && (paramכּ.ˎ.isConnected()))
i = 1;
else
i = 0;
if (i != 0)
{
int j = QuizApplication.ᐝ().ˋ.ʻ().ˊ;
if (j > 0)
{
Leaderboards localLeaderboards = Games.Leaderboards;
if (paramכּ.ˎ == null)
throw new IllegalStateException("No GoogleApiClient. Did you call setup()?");
localLeaderboards.submitScore(paramכּ.ˎ, this.ˋ.getString(2131165269), j);
ךּ.ˊ("RECEIVED_GAME_SERVICES_UPLOAD_LEADER_BOARD", new Object[0]);
}
}
}
示例8: getLeaderboards
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override
public void getLeaderboards(final GameServicesCallbacks.SuccessWithListListener<Leaderboard> leaderboardsListener) {
if (enableGameServices) {
Games.Leaderboards.loadLeaderboardMetadata(googleApiClient, true).setResultCallback(new ResultCallback<Leaderboards.LeaderboardMetadataResult>() {
@Override
public void onResult(Leaderboards.LeaderboardMetadataResult leaderboardMetadataResult) {
if (leaderboardMetadataResult.getStatus().isSuccess()) {
List<Leaderboard> result = new ArrayList<>();
for (com.google.android.gms.games.leaderboard.Leaderboard lb : leaderboardMetadataResult.getLeaderboards()) {
result.add(new Leaderboard(lb.getLeaderboardId(), Provider.GOOGLE, lb.getDisplayName(), lb.getIconImageUrl()));
}
leaderboardsListener.success(result, false);
} else {
leaderboardsListener.fail(leaderboardMetadataResult.getStatus().getStatusMessage());
}
}
});
} else {
leaderboardsListener.fail("To use GPGS features, please set `enableGameServices = true` in Google provider initialization parameters.");
}
}
示例9: submitScore
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override
public void submitScore(String leaderboardId, long value, final GameServicesCallbacks.SuccessWithScoreListener submitScoreListener) {
if (enableGameServices) {
Games.Leaderboards.submitScoreImmediate(googleApiClient, leaderboardId, value).setResultCallback(new ResultCallback<Leaderboards.SubmitScoreResult>() {
@Override
public void onResult(Leaderboards.SubmitScoreResult submitScoreResult) {
if (submitScoreResult.getStatus().isSuccess()) {
submitScoreListener.success(
new Score(
new Leaderboard(submitScoreResult.getScoreData().getLeaderboardId(), getProvider(), "", ""), // here is no iconURL and title at this moment
0, // rank is undefined here
SoomlaProfile.getInstance().getStoredUserProfile(getProvider()),
submitScoreResult.getScoreData().getScoreResult(LeaderboardVariant.TIME_SPAN_ALL_TIME).rawScore
)
);
} else {
submitScoreListener.fail(submitScoreResult.getStatus().getStatusMessage());
}
}
});
} else {
submitScoreListener.fail("To use GPGS features, please set `enableGameServices = true` in Google provider initialization parameters.");
}
}
示例10: submitHightScore
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
private static void submitHightScore(final Context context, final GoogleApiClient apiClient, final long highestScoreValue) {
LogX.i(TAG, "Submitting score to Google leaderboard");
final PendingResult<SubmitScoreResult> result = Games.Leaderboards.submitScoreImmediate(apiClient, getLeaderboardId(context), highestScoreValue);
result.setResultCallback(new ResultCallback<Leaderboards.SubmitScoreResult>() {
@Override
public void onResult(SubmitScoreResult finalResult) {
Status status = finalResult.getStatus();
LogX.i(TAG, "Result of the score submission: " + status);
if (status.getStatusCode() == GamesStatusCodes.STATUS_OK) {
PermData.saveHighestScoreSentToLeaderboard(context, highestScoreValue);
}
}
});
}
示例11: setSubmitScore
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
public void setSubmitScore(boolean callback, String submitScoreId,
long score) {
if (!callback) {
Games.Leaderboards.submitScore(mGoogleApiClient, submitScoreId,
score);
} else {
Games.Leaderboards.submitScoreImmediate(mGoogleApiClient,
submitScoreId, score).setResultCallback(
new ResultCallback<Leaderboards.SubmitScoreResult>() {
@Override
public void onResult(
Leaderboards.SubmitScoreResult submitScoreResult) {
if (mCallback != null) {
mCallback.onActionResult(
ActionType.SUBMIT_SCORE,
getStatusResult(submitScoreResult
.getStatus()));
}
}
});
}
}
示例12: loadScoreOfLeaderBoardIfLarger
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
private void loadScoreOfLeaderBoardIfLarger(final String leaderboardId, final int currentScore, final String gameDifficulty) {
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient, leaderboardId, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
@Override
public void onResult(final Leaderboards.LoadPlayerScoreResult scoreResult) {
if (isScoreResultValid(scoreResult)) {
// here you can get the score like this
int score = (int) scoreResult.getScore().getRawScore();
if (score > currentScore) {
SharedPreferences.Editor editor = getSharedPreferences(ResultsActivity.PREF_NAME, MODE_PRIVATE).edit();
editor.putInt(ResultsActivity.SCORE_PREFIX + gameDifficulty, score);
editor.apply();
}
}
}
});
}
示例13: showLeaderboards
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override
public void showLeaderboards(String leaderBoardId) throws GameServiceException {
if (isSessionActive()) {
if (gpgsLeaderboardIdMapper != null)
leaderBoardId = gpgsLeaderboardIdMapper.mapToGsId(leaderBoardId);
myContext.startActivityForResult(leaderBoardId != null ?
Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, leaderBoardId) :
Games.Leaderboards.getAllLeaderboardsIntent(mGoogleApiClient), RC_LEADERBOARD);
} else
throw new GameServiceException.NoSessionException();
}
示例14: submitToLeaderboard
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override
public boolean submitToLeaderboard(String leaderboardId, long score, String tag) {
if (gpgsLeaderboardIdMapper != null)
leaderboardId = gpgsLeaderboardIdMapper.mapToGsId(leaderboardId);
if (leaderboardId != null && isSessionActive()) {
if (tag != null)
Games.Leaderboards.submitScore(mGoogleApiClient, leaderboardId, score, tag);
else
Games.Leaderboards.submitScore(mGoogleApiClient, leaderboardId, score);
return true;
} else
return false;
}
示例15: submitScore
import com.google.android.gms.games.leaderboard.Leaderboards; //导入依赖的package包/类
@Override
public void submitScore(int highScore) {
if (isSignedIn()) {
Games.Leaderboards.submitScore(gameHelper.getApiClient(),
activity.getString(R.string.leaderboard_highscore), highScore);
}
}