private async void BtnSetNickName_Click(object sender, EventArgs e)
        {
            userNameEditText.Text = userNameEditText.Text.Replace(" ", "");
            if (userNameEditText.Text.Length < 4)
            {
                AlertsService.ShowLongToast(this, "Nick musi składać się z conajmniej czterech znaków");
            }
            else
            {
                try
                {
                    this.progressHelper.ShowProgressDialog("Przetwarzanie danych..");
                    bool result = await this.signInService.SetUserName(userNameEditText.Text, GetTokenModel());

                    this.progressHelper.CloseProgressDialog();
                    if (result)
                    {
                        SharedPreferencesHelper.SetUserNameInAppSettings(this, userNameEditText.Text);
                        StartMainOrLoginActivity(true);
                    }
                    else
                    {
                        AlertsService.ShowLongToast(this, "Podany nick jest już zajęty. Wpisz inny nick.");
                    }
                }
                catch (Exception exc)
                {
                    AlertsService.ShowLongToast(this, "Wystąpił błąd połączenia z serwerem.");
                    this.progressHelper.CloseProgressDialog();
                }
            }
        }
        private async Task <bool> SignInUser()
        {
            var userIsLogged = false;

            preferenceHelper = new SharedPreferencesHelper(this);
            var bearerToken = (string)preferenceHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);

            if (bearerToken != null)
            {
                userIsLogged = await signInService.SignInUserWithBearerToken(GetTokenModel());
            }
            if (!userIsLogged)
            {
                if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null)
                {
                    var facebookToken = new FacebookTokenViewModel {
                        FacebookToken = AccessToken.CurrentAccessToken.Token
                    };
                    var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken);

                    if (tokenModel != null)
                    {
                        preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
                        if (tokenModel.UserHasToSetNickName)
                        {
                            throw new UserHasToSetNickNameException();
                        }
                        else
                        {
                            SharedPreferencesHelper.SetUserNameInAppSettings(this, tokenModel.UserName);
                        }
                        userIsLogged = true;
                    }
                }
            }

            return(userIsLogged);
        }
 private void SetUserNameInAppSettings(string userName)
 {
     SharedPreferencesHelper.SetUserNameInAppSettings(this, userName);
 }