GetDefaultPopupView() публичный статический Метод

public static GetDefaultPopupView ( ) : AndroidJavaObject
Результат AndroidJavaObject
Пример #1
0
        ///<summary></summary>
        /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/>
        public void Authenticate(Action <bool, string> callback, bool silent)
        {
            lock (AuthStateLock)
            {
                // If the user is already authenticated, just fire the callback, we don't need
                // any additional work.
                if (mAuthState == AuthState.Authenticated)
                {
                    InvokeCallbackOnGameThread(callback, true, null);
                    return;
                }
            }

            InitializeTokenClient();

            Debug.Log("Starting Auth with token client.");
            mTokenClient.FetchTokens(silent, (int result) =>
            {
                bool succeed = result == 0 /* CommonStatusCodes.SUCCEED */;
                InitializeGameServices();
                if (succeed)
                {
                    using (var signInTasks = new AndroidJavaObject("java.util.ArrayList"))
                    {
                        if (mInvitationDelegate != null)
                        {
                            mInvitationCallback = new AndroidJavaObject(
                                "com.google.games.bridge.InvitationCallbackProxy",
                                new InvitationCallbackProxy(mInvitationDelegate));
                            using (var invitationsClient = getInvitationsClient())
                                using (var taskRegisterCallback =
                                           invitationsClient.Call <AndroidJavaObject>("registerInvitationCallback",
                                                                                      mInvitationCallback))
                                {
                                    signInTasks.Call <bool>("add", taskRegisterCallback);
                                }
                        }

                        AndroidJavaObject taskGetPlayer =
                            getPlayersClient().Call <AndroidJavaObject>("getCurrentPlayer");
                        AndroidJavaObject taskGetActivationHint =
                            getGamesClient().Call <AndroidJavaObject>("getActivationHint");
                        AndroidJavaObject taskIsCaptureSupported =
                            getVideosClient().Call <AndroidJavaObject>("isCaptureSupported");

                        if (!mConfiguration.IsHidingPopups)
                        {
                            AndroidJavaObject taskSetViewForPopups;
                            using (var popupView = AndroidHelperFragment.GetDefaultPopupView())
                            {
                                taskSetViewForPopups =
                                    getGamesClient().Call <AndroidJavaObject>("setViewForPopups", popupView);
                            }

                            signInTasks.Call <bool>("add", taskSetViewForPopups);
                        }

                        signInTasks.Call <bool>("add", taskGetPlayer);
                        signInTasks.Call <bool>("add", taskGetActivationHint);
                        signInTasks.Call <bool>("add", taskIsCaptureSupported);

                        using (var tasks = new AndroidJavaClass(TasksClassName))
                            using (var allTask = tasks.CallStatic <AndroidJavaObject>("whenAll", signInTasks))
                            {
                                AndroidTaskUtils.AddOnCompleteListener <AndroidJavaObject>(
                                    allTask,
                                    completeTask =>
                                {
                                    if (completeTask.Call <bool>("isSuccessful"))
                                    {
                                        using (var resultObject = taskGetPlayer.Call <AndroidJavaObject>("getResult"))
                                        {
                                            mUser = AndroidJavaConverter.ToPlayer(resultObject);
                                        }

                                        var account = mTokenClient.GetAccount();
                                        lock (GameServicesLock)
                                        {
                                            mSavedGameClient = new AndroidSavedGameClient(account);
                                            mEventsClient    = new AndroidEventsClient(account);
                                            bool isCaptureSupported;
                                            using (var resultObject =
                                                       taskIsCaptureSupported.Call <AndroidJavaObject>("getResult"))
                                            {
                                                isCaptureSupported = resultObject.Call <bool>("booleanValue");
                                            }

                                            mVideoClient     = new AndroidVideoClient(isCaptureSupported, account);
                                            mRealTimeClient  = new AndroidRealTimeMultiplayerClient(this, account);
                                            mTurnBasedClient = new AndroidTurnBasedMultiplayerClient(this, account);
                                            mTurnBasedClient.RegisterMatchDelegate(mConfiguration.MatchDelegate);
                                        }

                                        mAuthState = AuthState.Authenticated;
                                        InvokeCallbackOnGameThread(callback, true, "Authentication succeeded");
                                        GooglePlayGames.OurUtils.Logger.d("Authentication succeeded");
                                        try
                                        {
                                            using (var activationHint =
                                                       taskGetActivationHint.Call <AndroidJavaObject>("getResult"))
                                            {
                                                if (mInvitationDelegate != null)
                                                {
                                                    try
                                                    {
                                                        using (var invitationObject =
                                                                   activationHint.Call <AndroidJavaObject>("getParcelable",
                                                                                                           "invitation" /* Multiplayer.EXTRA_INVITATION */))
                                                        {
                                                            Invitation invitation =
                                                                AndroidJavaConverter.ToInvitation(invitationObject);
                                                            mInvitationDelegate(invitation, /* shouldAutoAccept= */
                                                                                true);
                                                        }
                                                    }
                                                    catch (Exception)
                                                    {
                                                        // handle null return
                                                    }
                                                }


                                                if (mTurnBasedClient.MatchDelegate != null)
                                                {
                                                    try
                                                    {
                                                        using (var matchObject =
                                                                   activationHint.Call <AndroidJavaObject>("getParcelable",
                                                                                                           "turn_based_match" /* Multiplayer#EXTRA_TURN_BASED_MATCH */)
                                                               )
                                                        {
                                                            TurnBasedMatch turnBasedMatch =
                                                                AndroidJavaConverter.ToTurnBasedMatch(matchObject);
                                                            mTurnBasedClient.MatchDelegate(
                                                                turnBasedMatch, /* shouldAutoLaunch= */ true);
                                                        }
                                                    }
                                                    catch (Exception)
                                                    {
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            // handle null return
                                        }

                                        LoadAchievements(ignore => { });
                                    }
                                    else
                                    {
                                        SignOut();
                                        InvokeCallbackOnGameThread(callback, false, "Authentication failed");
                                        GooglePlayGames.OurUtils.Logger.d("Authentication failed");
                                    }
                                }
                                    );
                            }
                    }
                }
                else
                {
                    lock (AuthStateLock)
                    {
                        if (result == 16 /* CommonStatusCodes.CANCELED */)
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication canceled");
                            GooglePlayGames.OurUtils.Logger.d("Authentication canceled");
                        }
                        else if (result == 8 /* CommonStatusCodes.DEVELOPER_ERROR */)
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication failed - developer error");
                            GooglePlayGames.OurUtils.Logger.d("Authentication failed - developer error");
                        }
                        else
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication failed");
                            GooglePlayGames.OurUtils.Logger.d("Authentication failed");
                        }
                    }
                }
            });
        }