// Path: core/src/de/golfgl/gdxgamesvcs/achievement/IFetchAchievementsResponseListener.java
// public interface IFetchAchievementsResponseListener {
// 
//     /**
//      * Response with achievement list
//      *
//      * @param achievements null if achievements couldn't be fetched.
//      */
//     void onFetchAchievementsResponse(Array<IAchievement> achievements);
// 
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/IFetchGameStatesListResponseListener.java
// public interface IFetchGameStatesListResponseListener {
//     /**
//      * Called when game state list was loaded
//      *
//      * @param gameStates null if game states couldn't be fetched.
//      */
//     void onFetchGameStatesListResponse(Array<String> gameStates);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/ILoadGameStateResponseListener.java
// public interface ILoadGameStateResponseListener {
//     /**
//      * Returns a game state that was saved in Cloud services
//      *
//      * @param gameState null if loading failed
//      */
//     public void gsGameStateLoaded(byte[] gameState);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/ISaveGameStateResponseListener.java
// public interface ISaveGameStateResponseListener {
// 
//     /**
//      * Result of save game request
//      *
//      * @param success   true if game state was sucessfully saved
//      * @param errorCode null if succesful
//      */
//     void onGameStateSaved(boolean success, String errorCode);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/leaderboard/IFetchLeaderBoardEntriesResponseListener.java
// public interface IFetchLeaderBoardEntriesResponseListener {
//     /**
//      * Called when leaderBoard entries are received.
//      *
//      * @param leaderBoard null if leaderBoard couldn't be fetched.
//      */
//     void onLeaderBoardResponse(Array<ILeaderBoardEntry> leaderBoard);
// }


import android.app.Activity;
import android.os.AsyncTask;
import android.os.SystemClock;
import com.amazon.ags.api.AGResponseCallback;
import com.amazon.ags.api.AmazonGamesCallback;
import com.amazon.ags.api.AmazonGamesClient;
import com.amazon.ags.api.AmazonGamesFeature;
import com.amazon.ags.api.AmazonGamesStatus;
import com.amazon.ags.api.overlay.PopUpLocation;
import com.amazon.ags.api.player.RequestPlayerResponse;
import com.amazon.ags.api.whispersync.FailReason;
import com.amazon.ags.api.whispersync.GameDataMap;
import com.amazon.ags.api.whispersync.WhispersyncEventListener;
import com.amazon.ags.api.whispersync.model.SyncableNumber;
import com.amazon.ags.api.whispersync.model.SyncableString;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Base64Coder;
import java.util.EnumSet;
import de.golfgl.gdxgamesvcs.achievement.IFetchAchievementsResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.IFetchGameStatesListResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.ILoadGameStateResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.ISaveGameStateResponseListener;
import de.golfgl.gdxgamesvcs.leaderboard.IFetchLeaderBoardEntriesResponseListener;
    protected void agcServiceNotReady(AmazonGamesStatus amazonGamesStatus) {
        Gdx.app.error(GS_CLIENT_ID, "onServiceNotReady - " + amazonGamesStatus.name());
        isConnectionPending = false;
        isConnected = false;
        if (gsListener != null) {
            gsListener.gsOnSessionInactive();
            if (!autoStartSignInFlow)
                gsListener.gsShowErrorToUser(IGameServiceListener.GsErrorType.errorLoginFailed,
                        amazonGamesStatus.name(), null);
        }
    }

    protected void agcServiceReady(AmazonGamesClient amazonGamesClient) {
        // The Amazon Game Service is ready, but that does not imply that an authenticated user session is active.
        // Therefore, check for the player
        Gdx.app.log(GS_CLIENT_ID, "onServiceReady");
        agsClient = amazonGamesClient;
        agsClient.setPopUpLocation(PopUpLocation.TOP_CENTER);

        // Request Alias
        AmazonGamesClient.getInstance().getPlayerClient().getLocalPlayer().setCallback(
                new AGResponseCallback<RequestPlayerResponse>() {
                    @Override
                    public void onComplete(final RequestPlayerResponse response) {
                        isConnectionPending = false;
                        isConnected = !response.isError();
                        Gdx.app.log(GS_CLIENT_ID, "Player response, connected: " + isConnected);

                        if (isConnected) {
                            cachedPlayerAlias = response.getPlayer().getAlias();
// Path: core/src/de/golfgl/gdxgamesvcs/achievement/IFetchAchievementsResponseListener.java
// public interface IFetchAchievementsResponseListener {
// 
//     /**
//      * Response with achievement list
//      *
//      * @param achievements null if achievements couldn't be fetched.
//      */
//     void onFetchAchievementsResponse(Array<IAchievement> achievements);
// 
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/IFetchGameStatesListResponseListener.java
// public interface IFetchGameStatesListResponseListener {
//     /**
//      * Called when game state list was loaded
//      *
//      * @param gameStates null if game states couldn't be fetched.
//      */
//     void onFetchGameStatesListResponse(Array<String> gameStates);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/ILoadGameStateResponseListener.java
// public interface ILoadGameStateResponseListener {
//     /**
//      * Returns a game state that was saved in Cloud services
//      *
//      * @param gameState null if loading failed
//      */
//     public void gsGameStateLoaded(byte[] gameState);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/gamestate/ISaveGameStateResponseListener.java
// public interface ISaveGameStateResponseListener {
// 
//     /**
//      * Result of save game request
//      *
//      * @param success   true if game state was sucessfully saved
//      * @param errorCode null if succesful
//      */
//     void onGameStateSaved(boolean success, String errorCode);
// }
// 
// Path: core/src/de/golfgl/gdxgamesvcs/leaderboard/IFetchLeaderBoardEntriesResponseListener.java
// public interface IFetchLeaderBoardEntriesResponseListener {
//     /**
//      * Called when leaderBoard entries are received.
//      *
//      * @param leaderBoard null if leaderBoard couldn't be fetched.
//      */
//     void onLeaderBoardResponse(Array<ILeaderBoardEntry> leaderBoard);
// }


// Path: android-amazongc/src/de/golfgl/gdxgamesvcs/GameCircleClient.java
import android.app.Activity;
import android.os.AsyncTask;
import android.os.SystemClock;
import com.amazon.ags.api.AGResponseCallback;
import com.amazon.ags.api.AmazonGamesCallback;
import com.amazon.ags.api.AmazonGamesClient;
import com.amazon.ags.api.AmazonGamesFeature;
import com.amazon.ags.api.AmazonGamesStatus;
import com.amazon.ags.api.overlay.PopUpLocation;
import com.amazon.ags.api.player.RequestPlayerResponse;
import com.amazon.ags.api.whispersync.FailReason;
import com.amazon.ags.api.whispersync.GameDataMap;
import com.amazon.ags.api.whispersync.WhispersyncEventListener;
import com.amazon.ags.api.whispersync.model.SyncableNumber;
import com.amazon.ags.api.whispersync.model.SyncableString;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Base64Coder;
import java.util.EnumSet;
import de.golfgl.gdxgamesvcs.achievement.IFetchAchievementsResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.IFetchGameStatesListResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.ILoadGameStateResponseListener;
import de.golfgl.gdxgamesvcs.gamestate.ISaveGameStateResponseListener;
import de.golfgl.gdxgamesvcs.leaderboard.IFetchLeaderBoardEntriesResponseListener;

    protected void agcServiceNotReady(AmazonGamesStatus amazonGamesStatus) {
        Gdx.app.error(GS_CLIENT_ID, "onServiceNotReady - " + amazonGamesStatus.name());
        isConnectionPending = false;
        isConnected = false;
        if (gsListener != null) {
            gsListener.gsOnSessionInactive();
            if (!autoStartSignInFlow)
                gsListener.gsShowErrorToUser(IGameServiceListener.GsErrorType.errorLoginFailed,
                        amazonGamesStatus.name(), null);
        }
    }

    protected void agcServiceReady(AmazonGamesClient amazonGamesClient) {
        // The Amazon Game Service is ready, but that does not imply that an authenticated user session is active.
        // Therefore, check for the player
        Gdx.app.log(GS_CLIENT_ID, "onServiceReady");
        agsClient = amazonGamesClient;
        agsClient.setPopUpLocation(PopUpLocation.TOP_CENTER);

        // Request Alias
        AmazonGamesClient.getInstance().getPlayerClient().getLocalPlayer().setCallback(
                new AGResponseCallback<RequestPlayerResponse>() {
                    @Override
                    public void onComplete(final RequestPlayerResponse response) {
                        isConnectionPending = false;
                        isConnected = !response.isError();
                        Gdx.app.log(GS_CLIENT_ID, "Player response, connected: " + isConnected);

                        if (isConnected) {
                            cachedPlayerAlias = response.getPlayer().getAlias();
                            if (gsListener != null)