Java Code Examples for com.google.android.gms.games.achievement.Achievement#getType()
The following examples show how to use
com.google.android.gms.games.achievement.Achievement#getType() .
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: AchievementsLoadListener.java From ANE-Google-Play-Game-Services with Apache License 2.0 | 6 votes |
@Override public void onAchievementsLoaded(int statusCode, AchievementBuffer achBuffer) { if (statusCode == GamesClient.STATUS_OK) { Iterator<Achievement> iterator = achBuffer.iterator(); while(iterator.hasNext()){ Achievement achievement = iterator.next(); if(achievement.getType() == Achievement.TYPE_INCREMENTAL && achievement.getAchievementId().equals(achievementId)) { this.incrementAchievementWhenDataIsLoaded(achievement); } } } else{ //Achievements loading has failed } achBuffer.close(); }
Example 2
Source File: GpgsClient.java From gdx-gamesvcs with Apache License 2.0 | 5 votes |
public boolean fetchAchievementsSync(IFetchAchievementsResponseListener callback) { if (!isSessionActive()) return false; Achievements.LoadAchievementsResult achievementsResult = Games.Achievements.load( mGoogleApiClient, forceRefresh).await(); if (!achievementsResult.getStatus().isSuccess()) { Gdx.app.log(GAMESERVICE_ID, "Failed to fetch achievements:" + achievementsResult.getStatus().getStatusMessage()); callback.onFetchAchievementsResponse(null); return false; } AchievementBuffer achievements = achievementsResult.getAchievements(); Array<IAchievement> gpgsAchs = new Array<IAchievement>(achievements.getCount()); for (Achievement ach : achievements) { GpgsAchievement gpgsAchievement = new GpgsAchievement(); gpgsAchievement.achievementId = ach.getAchievementId(); gpgsAchievement.achievementMapper = gpgsAchievementIdMapper; gpgsAchievement.description = ach.getDescription(); gpgsAchievement.title = ach.getName(); if (ach.getState() == Achievement.STATE_UNLOCKED) gpgsAchievement.percCompl = 1f; else if (ach.getType() == Achievement.TYPE_INCREMENTAL) gpgsAchievement.percCompl = (float) ach.getCurrentSteps() / ach.getTotalSteps(); gpgsAchs.add(gpgsAchievement); } achievements.release(); callback.onFetchAchievementsResponse(gpgsAchs); return true; }
Example 3
Source File: GooglePlay.java From ExtensionsPack with MIT License | 5 votes |
public void onAchievementsLoaded(int statusCode, AchievementBuffer buffer) { Log.i("trace", what + ": GooglePlayCallback.onAchievementsLoaded: " + statusCode); for(Achievement a : buffer) { String id = a.getAchievementId(); int state = a.getState(); int type = a.getType(); GooglePlay.connectionCallback.call("addAchievement", new Object[] {id, state, type}); } GooglePlay.connectionCallback.call("onAchievementsLoaded", new Object[]{}); }