コード例 #1
0
ファイル: ListActivity.cs プロジェクト: romap0/TaxiAuction
        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)));
            }
        }
コード例 #2
0
        private void CheckState( )
        {
            var state = Requests.GetState(UserInfo.UserId);

            if (state == "-50")
            {
                tmrState.Stop( );
                StartActivity(typeof(AuthActivity));
            }
        }
コード例 #3
0
ファイル: AuthActivity.cs プロジェクト: romap0/TaxiAuction
        private void Continue(string authResponse)
        {
            ThreadPool.QueueUserWorkItem(o =>
            {
                var state = Requests.GetState(authResponse);

                RunOnUiThread(() =>
                {
                    switch (state)
                    {
                    case "-50":
                        UserInfo.State = StateTypes.Free;
                        StartActivity(typeof(ListActivity));
                        break;

                    case "-51":
                        UserInfo.State  = StateTypes.ActiveOrder;
                        var activeOrder = Requests.GetActiveOrder(UserInfo.UserId);
                        if (activeOrder != null)
                        {
                            UserInfo.CurrentOrder = activeOrder;
                            StartActivity(typeof(OrderActivity));
                        }
                        else
                        {
                            Toast.MakeText(Application.Context, Resource.String.Error, ToastLength.Short).Show( );
                        }
                        break;

                    case "-52":
                        UserInfo.State       = StateTypes.PersonInCar;
                        var activeOrderInCar = Requests.GetActiveOrderInCar(UserInfo.UserId);
                        if (activeOrderInCar != null)
                        {
                            UserInfo.CurrentOrder = activeOrderInCar;
                            StartActivity(typeof(OrderActivity));
                        }
                        else
                        {
                            Toast.MakeText(Application.Context, Resource.String.Error, ToastLength.Short).Show( );
                        }
                        break;

                    case "-53":
                        UserInfo.State         = StateTypes.Arrived;
                        var activeOrderArrived = Requests.GetActiveOrder(UserInfo.UserId);
                        if (activeOrderArrived != null)
                        {
                            UserInfo.CurrentOrder = activeOrderArrived;
                            StartActivity(typeof(OrderActivity));
                        }
                        else
                        {
                            Toast.MakeText(Application.Context, Resource.String.Error, ToastLength.Short).Show( );
                        }
                        break;

                    default:
                        if (!activityIsVisible)
                        {
                            Start( );
                        }
                        Toast.MakeText(Application.Context, Resource.String.Error, ToastLength.Short).Show( );
                        break;
                    }
                });
            });
        }