com.google.android.gms.games.AnnotatedData Java Examples
The following examples show how to use
com.google.android.gms.games.AnnotatedData.
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: EventsController.java From PGSGP with MIT License | 9 votes |
public void loadEvents() { GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(activity); if (connectionController.isConnected().first && googleSignInAccount != null) { Games.getEventsClient(activity, googleSignInAccount) .load(true) .addOnCompleteListener(new OnCompleteListener<AnnotatedData<EventBuffer>>() { @Override public void onComplete(@NonNull Task<AnnotatedData<EventBuffer>> task) { if (task.isSuccessful() && task.getResult() != null) { EventBuffer events = task.getResult().get(); if (events != null) { JSONArray jsonArray = new JSONArray(); for (Event event : events) { jsonArray.put(eventInfoArray(event)); } godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED, new Object[]{jsonArray.toString()}); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_EMPTY, new Object[]{}); } } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{}); } } }); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{}); } }
Example #2
Source File: Request.java From play_games with MIT License | 6 votes |
private OnSuccessListener<AnnotatedData<LeaderboardsClient.LeaderboardScores>> scoreSuccessHandler() { return new OnSuccessListener<AnnotatedData<LeaderboardsClient.LeaderboardScores>>() { @Override public void onSuccess(AnnotatedData<LeaderboardsClient.LeaderboardScores> data) { LeaderboardsClient.LeaderboardScores scores = data.get(); Map<String, Object> successMap = new HashMap<>(); successMap.put("type", "SUCCESS"); successMap.put("leaderboardDisplayName", scores.getLeaderboard().getDisplayName()); List<Map<String, Object>> list = new ArrayList<>(); Iterator<LeaderboardScore> it = scores.getScores().iterator(); while (it.hasNext()) { list.add(scoreToMap(it.next())); } successMap.put("scores", list); scores.release(); result(successMap); } }; }
Example #3
Source File: EventsController.java From PGSGP with MIT License | 5 votes |
public void loadEventById(String[] eventIds) { GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(activity); if (connectionController.isConnected().first && googleSignInAccount != null) { Games.getEventsClient(activity, googleSignInAccount) .loadByIds(true, eventIds) .addOnCompleteListener(new OnCompleteListener<AnnotatedData<EventBuffer>>() { @Override public void onComplete(@NonNull Task<AnnotatedData<EventBuffer>> task) { if (task.isSuccessful() && task.getResult() != null) { EventBuffer events = task.getResult().get(); if (events != null) { JSONArray jsonArray = new JSONArray(); for (Event event : events) { jsonArray.put(eventInfoArray(event)); } godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED, new Object[]{jsonArray.toString()}); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_EMPTY, new Object[]{}); } } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{}); } } }); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{}); } }
Example #4
Source File: PlayerStatsController.java From PGSGP with MIT License | 5 votes |
public void checkPlayerStats(boolean forceRefresh) { GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(activity); if (connectionController.isConnected().first && googleSignInAccount != null) { Games.getPlayerStatsClient(activity, googleSignInAccount) .loadPlayerStats(forceRefresh) .addOnCompleteListener(new OnCompleteListener<AnnotatedData<PlayerStats>>() { @Override public void onComplete(@NonNull Task<AnnotatedData<PlayerStats>> task) { AnnotatedData<PlayerStats> result = task.getResult(); if (task.isSuccessful() && result != null && result.get() != null) { PlayerStats stats = result.get(); JSONObject json = new JSONObject(); try { json.put("avg_session_length", stats.getAverageSessionLength()); json.put("days_last_played", stats.getDaysSinceLastPlayed()); json.put("purchases", stats.getNumberOfPurchases()); json.put("sessions", stats.getNumberOfSessions()); json.put("session_percentile", stats.getSessionPercentile()); json.put("spend_percentile", stats.getSpendPercentile()); } catch (JSONException e) { e.printStackTrace(); } godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.PLAYER_STATS_LOADED, new Object[]{json.toString()}); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.PLAYER_STATS_LOADED_FAILED, new Object[]{}); } } }); } else { godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.PLAYER_STATS_LOADED_FAILED, new Object[]{}); } }
Example #5
Source File: MainActivity.java From android-basic-samples with Apache License 2.0 | 5 votes |
private void loadAndPrintEvents() { final MainActivity mainActivity = this; mEventsClient.load(true) .addOnSuccessListener(new OnSuccessListener<AnnotatedData<EventBuffer>>() { @Override public void onSuccess(AnnotatedData<EventBuffer> eventBufferAnnotatedData) { EventBuffer eventBuffer = eventBufferAnnotatedData.get(); int count = 0; if (eventBuffer != null) { count = eventBuffer.getCount(); } Log.i(TAG, "number of events: " + count); for (int i = 0; i < count; i++) { Event event = eventBuffer.get(i); Log.i(TAG, "event: " + event.getName() + " -> " + event.getValue()); } } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { handleException(e, getString(R.string.achievements_exception)); } }); }
Example #6
Source File: SnapshotCoordinator.java From android-basic-samples with Apache License 2.0 | 4 votes |
public Task<AnnotatedData<SnapshotMetadataBuffer>> load(SnapshotsClient snapshotsClient, boolean forceReload) { return snapshotsClient.load(forceReload); }