Nexmo / stitch-android-quickstart

A repository containing everything you need when getting started with the Nexmo Stitch API and the Android SDK
MIT License
2 stars 3 forks source link

We are not waiting for the synchronisation to be done #15

Open sdnazarenko opened 6 years ago

sdnazarenko commented 6 years ago

https://github.com/Nexmo/stitch-android-quickstart/blob/b16a210bac8fbbe66f54478942931df3b0dafdb8/examples/1-simple-conversation/app/src/main/java/com/nexmo/simpleconversation1/LoginActivity.java#L63

` private void login() { loginTxt.setText("Logging in...");

    String userToken = authenticate();
    conversationClient.login(userToken, new RequestHandler<User>() {
        @Override
        public void onSuccess(User user) {
            showLoginSuccess(user);

            conversationClient.synchronisationEvent().add(new ResultListener<SynchronisingState.STATE>() {
                @Override
                public void onSuccess(SynchronisingState.STATE result) {
                  if ( result == SynchronisingState.STATE.MEMBERS) {
                      logAndShow("Synchronization done");
                      runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              chatBtn.setVisibility(View.VISIBLE);
                          }
                      });
                  }
                }
            });
        }

        @Override
        public void onError(NexmoAPIError apiError) {
            logAndShow("Login Error: " + apiError.getMessage());
        }
    });
}

`

sdnazarenko commented 6 years ago

@ChrisGuzman please have a look