@@ -105,15 +105,15 @@ void Engine::InitGooglePlayGameServices() {
105105 *
106106 */
107107void Engine::OnAuthActionStarted (gpg::AuthOperation op) {
108- if (!initialized_resources_) return ;
108+ if (!initialized_resources_) {
109+ return ;
110+ }
111+
109112 ndk_helper::JNIHelper::GetInstance ()->RunOnUiThread ([this , op]() {
110113 EnableUI (false );
111- authorizing_ = true ;
112114 if (op == gpg::AuthOperation::SIGN_IN) {
113- LOGI (" Signing in to GPG" );
114115 status_text_->SetAttribute (" Text" , " Signing In..." );
115116 } else {
116- LOGI (" Signing out from GPG" );
117117 status_text_->SetAttribute (" Text" , " Signing Out..." );
118118 }
119119 });
@@ -136,11 +136,12 @@ void Engine::OnAuthActionFinished(gpg::AuthOperation op,
136136 });
137137 }
138138
139- if (!initialized_resources_) return ;
139+ if (!initialized_resources_) {
140+ return ;
141+ }
140142
141143 ndk_helper::JNIHelper::GetInstance ()->RunOnUiThread ([this , status]() {
142144 EnableUI (true );
143- authorizing_ = false ;
144145 button_sign_in_->SetAttribute (
145146 " Text" , gpg::IsSuccess (status) ? " Sign Out" : " Sign In" );
146147
@@ -560,8 +561,14 @@ void Engine::LeaveGame() {
560561 * invoking jui_helper functions to create java UIs
561562 */
562563void Engine::InitUI () {
564+ // The window initialization
565+ jui_helper::JUIWindow::Init (app_->activity , JUIHELPER_CLASS_NAME);
566+
563567 // Show toast with app label
564568 ndk_helper::JNIHelper::GetInstance ()->RunOnUiThread ([]() {
569+ if (NULL == jui_helper::JUIWindow::GetInstance ()->GetContext ()) {
570+ return ;
571+ }
565572 jui_helper::JUIToast toast (
566573 ndk_helper::JNIHelper::GetInstance ()->GetAppLabel ());
567574 toast.Show ();
@@ -572,9 +579,6 @@ void Engine::InitUI() {
572579 // UIs.
573580 //
574581
575- // The window initialization
576- jui_helper::JUIWindow::Init (app_->activity , JUIHELPER_CLASS_NAME);
577-
578582 //
579583 // Buttons
580584 //
@@ -586,7 +590,6 @@ void Engine::InitUI() {
586590 jui_helper::LAYOUT_PARAMETER_TRUE);
587591 button_sign_in_->SetCallback ([this ](jui_helper::JUIView *view,
588592 const int32_t message) {
589- LOGI (" button_sign_in_ click: %d" , message);
590593 if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
591594 if (service_->IsAuthorized ()) {
592595 service_->SignOut ();
@@ -647,7 +650,6 @@ void Engine::InitUI() {
647650 // Init play game services
648651 InitGooglePlayGameServices ();
649652
650- if (authorizing_) EnableUI (false );
651653 return ;
652654}
653655
@@ -669,7 +671,6 @@ void Engine::SetParameters(jui_helper::JUIButton *button,
669671 * Enable/Disable management UI
670672 */
671673void Engine::EnableUI (bool enable) {
672- LOGI (" Updating UI:%d" , enable);
673674 ndk_helper::JNIHelper::GetInstance ()->RunOnUiThread ([this , enable]() {
674675 button_sign_in_->SetAttribute (" Enabled" , enable);
675676
0 commit comments