@Override
 public void register(
     String email, String password, boolean agreeConditions, boolean autoCreateChatbox) {
   mProgressViewsManager.showProgress(true, R.string.progress_registering);
   RegisterTask task = mRegisterTaskProvider.get();
   task.setParams(email, password, agreeConditions, autoCreateChatbox);
   startTask(task.execute());
 }
  private void handleRegisterTaskFinished(TaskFinishedEvent event, RegisterTask task) {
    if (event.getStatus() == TaskFinishedEvent.Status.FAILED) {
      mProgressViewsManager.showProgress(false);

      Exception exception = event.getException();
      if (exception instanceof EmailValidator.InvalidEmailException) {
        showEmailError(getString(R.string.error_invalid_email));
        return;
      }
      if (exception instanceof PasswordValidator.InvalidPasswordException) {
        showPasswordError(getString(R.string.error_invalid_password));
        return;
      }
      if (exception instanceof ApiManager.ValidationException) {
        // Throws by server error code, we can have more detail error from server but let's me it
        // confusing here
        showEmailError(getString(R.string.error_invalid_username_password));
        return;
      }

      if (exception instanceof ApiManager.OtherApplicationException) {
        mErrorMessageView.show(
            ((ApiManager.OtherApplicationException) exception).getError().getMessage());
        return;
      }

      // Other exceptions/error let boss handles it
      mErrorMessageView.show(exception);
      return;
    }

    // Registered successfully, should start session to get authenticated
    // session now.
    AuthenticationParams params =
        mBuildManager.isCustomLoginType()
            ? new AppOAuthParams(task.getEmail(), task.getPassword())
            : new ChatwingOAuthParams(task.getEmail(), task.getPassword());
    startSession(params);
  }