Summary: Constants | Methods | Inherited Methods | [Expand All]
public interface

# LeaderboardVariant

implements Freezable<LeaderboardVariant>

com.google.android.gms.games.leaderboard.LeaderboardVariant

## Class Overview

Data interface for a specific variant of a leaderboard; a variant is defined by the combination of the leaderboard's collection (public or social) and time span (daily, weekly, or all-time).

## Summary

Constants
int | COLLECTION_PUBLIC | Collection constant for public leaderboards.
int | COLLECTION_SOCIAL | Collection constant for social leaderboards.
int | NUM_SCORES_UNKNOWN | Constant returned when the total number of scores for this variant is unknown.
int | NUM_TIME_SPANS | Number of time spans that exist.
int | PLAYER_RANK_UNKNOWN | Constant returned when a player's rank for this variant is unknown.
int | PLAYER_SCORE_UNKNOWN | Constant returned when a player's score for this variant is unknown.
int | TIME_SPAN_ALL_TIME | Scores are never reset.
int | TIME_SPAN_DAILY | Scores are reset every day.
int | TIME_SPAN_WEEKLY | Scores are reset once per week.

Public Methods
abstract int | getCollection() Retrieves the collection of scores contained by this variant.
abstract String | getDisplayPlayerRank() Retrieves the viewing player's formatted rank for this variant, if any.
abstract String | getDisplayPlayerScore() Retrieves the viewing player's score for this variant, if any.
abstract long | getNumScores() Retrieves the total number of scores for this variant.
abstract long | getPlayerRank() Retrieves the viewing player's rank for this variant, if any.
abstract String | getPlayerScoreTag() Retrieves the viewing player's score tag for this variant, if any.
abstract long | getRawPlayerScore() Retrieves the viewing player's score for this variant, if any.
abstract int | getTimeSpan() Retrieves the time span that the scores for this variant are drawn from.
abstract boolean | hasPlayerInfo() Get whether or not this variant contains score information for the viewing player or not.

[Expand] Inherited Methods
From interface com.google.android.gms.common.data.Freezable
abstract LeaderboardVariant | freeze() Freeze a volatile representation into an immutable representation.
abstract boolean | isDataValid() Check to see if this object is valid for use.

## Constants

#### public static final int COLLECTION_PUBLIC

Collection constant for public leaderboards. Public leaderboards contain the scores of players who are sharing their gameplay activity publicly.

Constant Value: 0 (0x00000000)

#### public static final int COLLECTION_SOCIAL

Collection constant for social leaderboards. Social leaderboards contain the scores of players in the viewing player's circles.

Constant Value: 1 (0x00000001)

#### public static final int NUM_SCORES_UNKNOWN

Constant returned when the total number of scores for this variant is unknown.

Constant Value: -1 (0xffffffff)

#### public static final int NUM_TIME_SPANS

Number of time spans that exist. Needs to be updated if we ever have more.

Constant Value: 3 (0x00000003)

#### public static final int PLAYER_RANK_UNKNOWN

Constant returned when a player's rank for this variant is unknown.

Constant Value: -1 (0xffffffff)

#### public static final int PLAYER_SCORE_UNKNOWN

Constant returned when a player's score for this variant is unknown.

Constant Value: -1 (0xffffffff)

#### public static final int TIME_SPAN_ALL_TIME

Scores are never reset.

Constant Value: 2 (0x00000002)

#### public static final int TIME_SPAN_DAILY

Scores are reset every day. The reset occurs at 11:59PM PST.

Constant Value: 0 (0x00000000)

#### public static final int TIME_SPAN_WEEKLY

Scores are reset once per week. The reset occurs at 11:59PM PST on Sunday.

Constant Value: 1 (0x00000001)

## Public Methods

#### public abstract int getCollection ()

Retrieves the collection of scores contained by this variant. Possible values are `COLLECTION_PUBLIC` or `COLLECTION_SOCIAL`.

##### Returns

- The collection of scores contained by this variant.

#### public abstract String getDisplayPlayerRank ()

Retrieves the viewing player's formatted rank for this variant, if any. Note that this value is only accurate if `hasPlayerInfo()` returns true.

##### Returns

- The String representation of the viewing player's rank, or {@code null) if the player has no rank for this variant.

#### public abstract String getDisplayPlayerScore ()

Retrieves the viewing player's score for this variant, if any. Note that this value is only accurate if `hasPlayerInfo()` returns true.

##### Returns

- The String representation of the viewing player's score, or `null` if the player has no score for this variant.

#### public abstract long getNumScores ()

Retrieves the total number of scores for this variant. Not all of these scores will always be present on the local device. Note that if scores for this variant have not been loaded, this method will return `NUM_SCORES_UNKNOWN`.

##### Returns

- The number of scores for this variant, or `NUM_SCORES_UNKNOWN`.

#### public abstract long getPlayerRank ()

Retrieves the viewing player's rank for this variant, if any. Note that this value is only accurate if `hasPlayerInfo()` returns true.

##### Returns

- The long representation of the viewing player's rank, or `PLAYER_RANK_UNKNOWN` if the player has no rank for this variant.

#### public abstract String getPlayerScoreTag ()

Retrieves the viewing player's score tag for this variant, if any. Note that this value is only accurate if `hasPlayerInfo()` returns true.

##### Returns

- The score tag associated with the viewing player's score, or `null` if the player has no score for this variant.

#### public abstract long getRawPlayerScore ()

Retrieves the viewing player's score for this variant, if any. Note that this value is only accurate if `hasPlayerInfo()` returns true.

##### Returns

- The long representation of the viewing player's score, or `PLAYER_SCORE_UNKNOWN` if the player has no score for this variant.

#### public abstract int getTimeSpan ()

Retrieves the time span that the scores for this variant are drawn from. Possible values are `TIME_SPAN_ALL_TIME`, `TIME_SPAN_WEEKLY`, or `TIME_SPAN_DAILY`.

##### Returns

- The time span that the scores for this variant are drawn from.

#### public abstract boolean hasPlayerInfo ()

Get whether or not this variant contains score information for the viewing player or not. There are several possible reasons why this might be false. If the scores for this variant have never been loaded, we won't know if the player has a score or not. Similarly, if the player has not submitted a score for this variant, this will return false.

It is possible to have a score but no rank. For instance, on leaderboard variants of `COLLECTION_PUBLIC`, players who are not sharing their scores publicly will never have a rank.

##### Returns

- Whether or not this variant contains score information for the viewing player.