Beispiel #1
0
        private void Refresh( )
        {
            var state = Requests.GetState(UserInfo.UserId);

            if (state == "-50")
            {
                OrdersList       = Requests.GetOrdersList(UserInfo.UserId);
                UserInfo.Balance = Requests.GetBalance(UserInfo.UserId);

                RunOnUiThread(() =>
                {
                    if (OrdersList != null)
                    {
                        lstOrders.Visibility   = ViewStates.Visible;
                        txtNoOrders.Visibility = ViewStates.Gone;
                        lstOrders.Adapter      = new OrdersListAdapter(this, OrdersList);
                    }
                    else
                    {
                        lstOrders.Visibility   = ViewStates.Gone;
                        txtNoOrders.Visibility = ViewStates.Visible;
                    }

                    LegacyBar.ProgressBarVisibility = ViewStates.Gone;
                    LegacyBar.Title = "Баланс: " + UserInfo.Balance;
                });
            }
            else
            {
                tmrState.Stop( );
                RunOnUiThread(() => StartActivity(typeof(AuthActivity)));
            }
        }
Beispiel #2
0
        private void GetBalance( )
        {
            var balance = Requests.GetBalance(UserInfo.UserId);

            RunOnUiThread(() =>
            {
                if (balance != null)
                {
                    Toast.MakeText(Application.Context, String.Format("Ваш баланс: {0} руб.", balance), ToastLength.Long).Show( );
                }
                else
                {
                    Toast.MakeText(Application.Context, Resource.String.Error, ToastLength.Long).Show( );
                }

                LegacyBar.ProgressBarVisibility = ViewStates.Gone;
            });
        }
Beispiel #3
0
        private void Login( )
        {
            var authResponse = Requests.Authorize(txtLicense.Text, txtPassword.Text, UserInfo.PushId);

            int intResponse;
            var responseIsParsed = int.TryParse(authResponse, out intResponse);

            if (responseIsParsed && intResponse > 0)
            {
                UserInfo.UserId  = authResponse;
                UserInfo.License = txtLicense.Text;

                var editor = GetSharedPreferences(Application.Context.PackageName, FileCreationMode.Private).Edit( );
                editor.PutString("UserId", UserInfo.UserId);
                editor.PutString("PushId", UserInfo.PushId);
                editor.PutString("License", txtLicense.Text);
                editor.PutString("Password", Crypto.EncryptStringAES(txtPassword.Text, SharedSecret));
                editor.Commit( );

                UserInfo.MagicNumber = Requests.GetMagicNumber( );
                UserInfo.Balance     = Requests.GetBalance(UserInfo.UserId);

                if (Requests.GetMode(UserInfo.UserId) == "2")
                {
                    PreferenceManager.GetDefaultSharedPreferences(this).Edit( ).PutBoolean("UseGPS", false).Commit( );
                    UserInfo.Area = Requests.GetArea(UserInfo.UserId);
                }
                else
                {
                    PreferenceManager.GetDefaultSharedPreferences(this).Edit( ).PutBoolean("UseGPS", true).Commit( );
                }

                RunOnUiThread(() => CheckState(UserInfo.UserId));
            }
            else
            {
                RunOnUiThread(() =>
                {
                    LegacyBar.ProgressBarVisibility = ViewStates.Gone;

                    switch (authResponse)
                    {
                    case "-1": lblError.SetText(Resource.String.Error_1);
                        break;

                    case "-2": lblError.SetText(Resource.String.Error_2);
                        break;

                    case "-3": lblError.SetText(Resource.String.Error_3);
                        break;

                    case "-4": lblError.SetText(Resource.String.Error_4);
                        break;

                    case "-5": lblError.SetText(Resource.String.Error_5);
                        break;

                    default: lblError.SetText(Resource.String.Error);
                        break;
                    }
                });
            }
        }