public override async void ViewDidLoad() { try { await goods.GetNext(); await OrderController.GetInstance(); source = new GoodsSource(goods.List); source.RemoveKeyboard += Source_RemoveKeyboard; GoodsTableView.Source = source; GoodsTableView.ReloadData(); ActivityIndicator.StopAnimating(); this.source.UploadNextItems += async(s, e) => { if (isAsyncUpdateAlowed) { isAsyncUpdateAlowed = false; ActivityIndicator.StartAnimating(); if (await goods.GetNext()) { GoodsTableView.ReloadData(); } ActivityIndicator.StopAnimating(); isAsyncUpdateAlowed = true; } }; this.DrugSearchBar.SearchButtonClicked += async(object sender, EventArgs e) => { ActivityIndicator.StartAnimating(); this.DrugSearchBar.ResignFirstResponder(); List <Goods> search = await goods.Search((sender as UISearchBar).Text); ActivityIndicator.StopAnimating(); GoodsSource sou = new GoodsSource(search); sou.RemoveKeyboard += Source_RemoveKeyboard; GoodsTableView.Source = sou; GoodsTableView.ReloadData(); }; this.DrugSearchBar.TextChanged += (object sender, UISearchBarTextChangedEventArgs e) => { if (String.IsNullOrWhiteSpace(e.SearchText)) { this.DrugSearchBar.ResignFirstResponder(); GoodsTableView.Source = source; GoodsTableView.ReloadData(); } }; } catch { ActivityIndicator.StopAnimating(); PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }
public override void ViewDidLoad() { _didShowNotificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardDidShow, this); _willHideNotificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardWillHide, this); ActivityIndicator.StopAnimating(); this.LoginField.ShouldReturn += (textField) => textField.ResignFirstResponder(); this.PasswordField.ShouldReturn += (textField) => textField.ResignFirstResponder(); this.AdressField.ShouldReturn += (textField) => textField.ResignFirstResponder(); this.PhoneNumberField.ShouldReturn += (textField) => textField.ResignFirstResponder(); this.View.AddGestureRecognizer(new UITapGestureRecognizer(() => { LoginField.ResignFirstResponder(); PasswordField.ResignFirstResponder(); AdressField.ResignFirstResponder(); PhoneNumberField.ResignFirstResponder(); })); RegistrationButton.TouchUpInside += async(sender, e) => { Customers registrationFieldsForAsync = new Customers() { Name = LoginField.Text, Password = PasswordField.Text, Adress = AdressField.Text, PhoneNumber = PhoneNumberField.Text }; ActivityIndicator.StartAnimating(); try { RegistrationButton.Enabled = false; LoginAndPasswordCheck.LoginCheck(registrationFieldsForAsync.Name); LoginAndPasswordCheck.PasswordCheck(registrationFieldsForAsync.Password); LoginAndPasswordCheck.AdressCheck(registrationFieldsForAsync.Adress); LoginAndPasswordCheck.PhoneCheck(registrationFieldsForAsync.PhoneNumber); await UsersCheckClass.TryToRegister(registrationFieldsForAsync); AppDelegate.UserName = registrationFieldsForAsync.Name; PerformSegue("RegistrationSegue", null); } catch (FiledsCheckException e1) { ActivityIndicator.StopAnimating(); RegistrationButton.Enabled = true; PresentViewController(GetAlertsClass.GetAlert(e1.Message), true, null); } catch (UserCheckClassException e1) { ActivityIndicator.StopAnimating(); RegistrationButton.Enabled = true; PresentViewController(GetAlertsClass.GetAlert(e1.Message), true, null); } catch { ActivityIndicator.StopAnimating(); RegistrationButton.Enabled = true; PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }; }
public override async void ViewDidLoad() { try { UIBarButtonItem GoToMapBarItem = new UIBarButtonItem(); GoToMapBarItem.Image = UIImage.FromBundle("Map"); GoToMapBarItem.Clicked += (sender, e) => { PerformSegue("MapSegue", this); }; this.NavigationItem.SetRightBarButtonItem(GoToMapBarItem, true); this.orders = await OrderController.GetInstance(); itemOrder = (from i in orders.ListOfOrders where i.Name == item.Name select i).ToList(); AddButton.TouchUpInside += async(sender, e) => { AddButton.Enabled = false; CountStepper.Enabled = false; this.AddButton.BackgroundColor = UIColor.Red; this.DrugAvailabilityImage.Image = UIImage.FromBundle("Sending"); if (itemOrder.Count == 0) { await orders.AddOrder(new Orders(AppDelegate.UserName, item.Name, false, (int)CountStepper.Value)); orders.ListOfOrders.Add(new OrderItem(item) { Derived = false }); PresentViewController(GetAlertsClass.GetAlertForOrder("Ожидайте заказа"), true, null); } else { await orders.UpdateOrder(new Orders(AppDelegate.UserName, item.Name, false, (int)CountStepper.Value)); itemOrder[0].Derived = false; PresentViewController(GetAlertsClass.GetAlertForOrder("Ожидайте заказа"), true, null); } }; CountStepper.ValueChanged += (object sender, EventArgs e) => { this.DrugCountLabel.Text = (int)((UIStepper)sender).Value + " шт."; this.DrugPriceLabel.Text = ((int)((UIStepper)sender).Value * item.Price) + " BYR"; }; InitInputs(); } catch { PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }
public async override void ViewDidLoad() { MobileService = new MobileServiceClient("https://some.azurewebsites.net"); AdressesTable = MobileService.GetTable <Adresses>(); try { await InitList(); cLLocationManager = new CLLocationManager(); cLLocationManager.RequestWhenInUseAuthorization(); MapView.Delegate = new MapViewDelegeate(); MapView.AddAnnotations(annots.ToArray()); } catch { PresentViewController(GetAlertsClass.GetAlert("Проблемы с геолокацией"), true, null); } }
public async override void ViewDidLoad() { try { orders = await OrderController.GetInstance(); OrdersSource source = new OrdersSource(orders.ListOfOrders); OrderTableView.Source = source; OrderTableView.ReloadData(); ActivityIndicator.StopAnimating(); this.RefreshControl = new UIRefreshControl(); this.RefreshControl.ValueChanged += (sender, e) => { this.RefreshControl.BeginRefreshing(); OrderTableView.ReloadData(); this.RefreshControl.EndRefreshing(); }; } catch { ActivityIndicator.StopAnimating(); PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }