public class SwarmLeaderboard
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SwarmLeaderboard.DateRange
Various available Leaderboard score date ranges.
|
static class |
SwarmLeaderboard.Direction
Leaderboard sort direction.
|
static class |
SwarmLeaderboard.GotLeaderboardCB |
static class |
SwarmLeaderboard.GotLeaderboardsListCB |
static class |
SwarmLeaderboard.GotScoreCB |
static class |
SwarmLeaderboard.GotScoresCB |
static class |
SwarmLeaderboard.KeepScores
Keep the best scores, or keep the most recent scores submitted to this leaderboard.
|
static class |
SwarmLeaderboard.LeaderboardFormat
The enum for the different available Leaderboard format types.
|
static class |
SwarmLeaderboard.SocialScope
Various available Leaderboard score scopes.
|
static class |
SwarmLeaderboard.SubmitScoreCB |
Modifier and Type | Field and Description |
---|---|
SwarmLeaderboard.Direction |
direction |
SwarmLeaderboard.LeaderboardFormat |
format
This Leaderboard's format.
|
int |
id
This Leaderboard's unique integer identification number.
|
int |
keep_count
The number of scores to keep per player on the leaderboard.
|
SwarmLeaderboard.KeepScores |
keep_scores |
int |
max_version
The maximum app version number that will use this leaderboard
|
int |
min_version
The minimum app version number that will use this leaderboard.
|
java.lang.String |
name
This Leaderboard's name (i.e.
|
Constructor and Description |
---|
SwarmLeaderboard() |
Modifier and Type | Method and Description |
---|---|
static void |
getLeaderboardById(int leaderboardId,
SwarmLeaderboard.GotLeaderboardCB cb)
Get a specified Leaderboard.
|
static void |
getLeaderboardsList(SwarmLeaderboard.GotLeaderboardsListCB cb)
Get a list of available Leaderboards for this application.
|
void |
getPageOfScores(int pageNum,
SwarmLeaderboard.DateRange dateRange,
SwarmLeaderboard.SocialScope scope,
SwarmLeaderboard.GotScoresCB cb)
Get a specified page of scores for this Leaderboard.
|
void |
getPageOfScoresForCurrentUser(SwarmLeaderboard.DateRange dateRange,
SwarmLeaderboard.GotScoresCB cb)
Get the page of scores for this Leaderboard that contains the user's score.
|
void |
getScoreForUser(int userId,
SwarmLeaderboard.GotScoreCB cb)
Get the SwarmLeaderboardScore for a particular user on this Leaderboard.
|
void |
getScoreForUser(SwarmUser user,
SwarmLeaderboard.GotScoreCB cb)
Get the SwarmLeaderboardScore for a particular user on this Leaderboard.
|
void |
getTopScores(SwarmLeaderboard.DateRange dateRange,
SwarmLeaderboard.GotScoresCB cb)
Get the top page of scores for this Leaderboard.
|
void |
showLeaderboard()
Display this Leaderboard to the user.
|
static void |
showLeaderboard(int leaderboardId)
Display the specified Leaderboard to the user.
|
static void |
showLeaderboard(int leaderboardId,
SwarmLeaderboard.DateRange dateRange)
Display the specified Leaderboard to the user with the specified default date range using one of SwarmLeaderboard.DateRange.XXXXX values.
|
void |
showLeaderboard(SwarmLeaderboard.DateRange dateRange)
Display this Leaderboard to the user with the specified default date range using one of SwarmLeaderboard.DateRange.XXXXX values
|
void |
submitScore(float score)
Submit a score to this Leaderboard.
|
void |
submitScore(float score,
java.lang.String data)
Submit a score to this Leaderboard.
|
void |
submitScore(float score,
java.lang.String data,
SwarmLeaderboard.SubmitScoreCB cb)
Submit a score to this Leaderboard.
|
static void |
submitScore(int leaderboardId,
float score)
Submit a score to the specified Leaderboard.
|
static void |
submitScore(int leaderboardId,
float score,
java.lang.String data)
Submit a score to the specified Leaderboard.
|
static void |
submitScore(int leaderboardId,
float score,
java.lang.String data,
SwarmLeaderboard.SubmitScoreCB cb)
Submit a score to the specified Leaderboard.
|
static void |
submitScoreAndShowLeaderboard(int leaderboardId,
float score)
Submit a score to the specified Leaderboard and then immediately show the specified Leaderboard.
|
static void |
submitScoreAndShowLeaderboard(int leaderboardId,
float score,
java.lang.String data)
Submit a score to the specified Leaderboard and then immediately show the specified Leaderboard.
|
public int id
public java.lang.String name
public SwarmLeaderboard.LeaderboardFormat format
public int min_version
public int max_version
public SwarmLeaderboard.Direction direction
public SwarmLeaderboard.KeepScores keep_scores
public int keep_count
public void showLeaderboard()
public void showLeaderboard(SwarmLeaderboard.DateRange dateRange)
dateRange
- The default date range for scores shown on the Leaderboard (i.e., day, week, month, all time). Use one of the SwarmLeaderboard.DateRange.XXXXX values.public static void showLeaderboard(int leaderboardId)
leaderboardId
- The identification number of the leaderboard to display.public static void showLeaderboard(int leaderboardId, SwarmLeaderboard.DateRange dateRange)
leaderboardId
- The identification number of the Leaderboard to display.dateRange
- The default date range for scores shown on the Leaderboard (i.e., day, week, month, all time). Use one of the SwarmLeaderboard.DateRange.XXXXX values.public void submitScore(float score)
score
- The score to be submitted.public void submitScore(float score, java.lang.String data)
score
- The score to be submitted.data
- A payload String that is included with the score submission. If not needed, an empty string is an acceptable value.public void submitScore(float score, java.lang.String data, SwarmLeaderboard.SubmitScoreCB cb)
score
- The score to be submitted.data
- A payload String that is included with the score submission. If not needed, an empty string is an acceptable value.cb
- The callback that returns after an attempt to submit the score. If the submission is successful
the callback returns the user's Leaderboard rank (in the form of an int) and displays a Swarm notification to the user
which contains the user's score. If the submission fails, then the callback returns -1.public static void submitScore(int leaderboardId, float score)
submitScoreAndShowLeaderboard(int, float)
.leaderboardId
- The identification number of the leaderboardscore
- The score to be submitted.public static void submitScore(int leaderboardId, float score, java.lang.String data)
submitScoreAndShowLeaderboard(int, float, String)
.leaderboardId
- The identification number of the leaderboard.score
- The score to be submitted.data
- A payload String that is included with the score submission. null-safe.public static void submitScore(int leaderboardId, float score, java.lang.String data, SwarmLeaderboard.SubmitScoreCB cb)
leaderboardId
- The identification number of the leaderboard.score
- The score to be submitted.data
- A payload String that is included with the score submission. If not needed, an empty string is an acceptable value.The
- callback that returns after an attempt to submit the score. If the submission is successful
the callback returns the user's Leaderboard rank (in the form of an int) and displays a Swarm notification to the user
which contains the user's name, user's rank, and user's score. If the submission fails, then the callback
returns -1.public static void submitScoreAndShowLeaderboard(int leaderboardId, float score)
leaderboardId
- The identification number of the Leaderboardscore
- The score to be submitted.public static void submitScoreAndShowLeaderboard(int leaderboardId, float score, java.lang.String data)
leaderboardId
- The identification number of the Leaderboardscore
- The score to be submitted.data
- A payload String that is included with the score submission. If not needed, an empty string is an acceptable value.public void getTopScores(SwarmLeaderboard.DateRange dateRange, SwarmLeaderboard.GotScoresCB cb)
dateRange
- The date range requested, one of SwarmLeaderboard.DateRange.XXXXX.cb
- The callback returns the Leaderboard page number and Leaderboard ID on success, and returns -1 on failure.public void getPageOfScoresForCurrentUser(SwarmLeaderboard.DateRange dateRange, SwarmLeaderboard.GotScoresCB cb)
dateRange
- The date range requested, one of SwarmLeaderboard.DateRange.XXXXX.cb
- The callback returns the Leaderboard page number and Leaderboard ID on success, and returns -1 on failure.public void getPageOfScores(int pageNum, SwarmLeaderboard.DateRange dateRange, SwarmLeaderboard.SocialScope scope, SwarmLeaderboard.GotScoresCB cb)
pageNum
- The Leaderboard page number requested.dateRange
- The date range requested, one of SwarmLeaderboard.DateRange.XXXXXX.scope
- The scope of the scores requested, one of SwarmLeaderboard.SocialScope.XXXXXX.cb
- The callback returns the Leaderboard page number and Leaderboard ID on success, and returns -1 on failure.public void getScoreForUser(int userId, SwarmLeaderboard.GotScoreCB cb)
userId
- The SwarmUser userId requested.cb
- The callback returns a SwarmLeaderboardScore on success, null on failure.public void getScoreForUser(SwarmUser user, SwarmLeaderboard.GotScoreCB cb)
userId
- The SwarmUser userId requested.cb
- The callback returns a SwarmLeaderboardScore on success, null on failure.public static void getLeaderboardById(int leaderboardId, SwarmLeaderboard.GotLeaderboardCB cb)
leaderboardId
- The Leaderboard ID of the Leaderboard being requested.cb
- Returns the specified Leaderboard on success, and returns null on failure.public static void getLeaderboardsList(SwarmLeaderboard.GotLeaderboardsListCB cb)
cb
- Returns a list of Leaderboard objects on success, and returns null on failure.