Beispiel #1
0
        async void OnPlaceSelected()
        {
            var detailsViewModel = new DetailsViewModel
            {
                Position = viewModel.Position,
                Place    = currentPlace
            };

            ShowProgress(true);

            bool success = await detailsViewModel.RefreshPlace();

            if (!success)
            {
                var alertController = UIAlertController.Create(string.Empty, "unable_to_get_details".LocalizedString("Details request failure message"), UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("ok".LocalizedString("OK title for button"), UIAlertActionStyle.Destructive, null));
                ShowViewController(alertController, this);
                return;
            }

            ServiceContainer.RegisterScoped <DetailsViewModel>(detailsViewModel);

            ShowViewController(Storyboard.Instantiate <PlaceDetailsViewController>(), this);

            ShowProgress(false);
        }
        async void UpdatePlaceInfo()
        {
            await viewModel.RefreshPlace();

            var reviewsButtonTitle = viewModel.Place.HasReviews ?
                                     string.Format("{0} {1}", viewModel.Place.Reviews.Count, "reviews".LocalizedString("Title of the reviews button")) :
                                     "no_reviews".LocalizedString("If place have no reviews");

            SetButton(ReviewsButton, reviewsButtonTitle, viewModel.Place.HasReviews);

            var photosButtonTitle = viewModel.Place.HasImage ?
                                    string.Format("{0} {1}", viewModel.Place.Photos.Count, "photos".LocalizedString("Title of the photos button")) :
                                    "no_photos".LocalizedString("If place have no photos");

            SetButton(PhotosButton, photosButtonTitle, viewModel.Place.HasImage);
        }
Beispiel #3
0
 private void RefreshData()
 {
     viewModel.RefreshPlace().ContinueWith((result) => {
         RunOnUiThread(() => {
             SupportActionBar.CustomView.Visibility = ViewStates.Gone;
             if (!result.Result)
             {
                 Toast.MakeText(this, Resource.String.unable_to_get_details, ToastLength.Long).Show();
                 return;
             }
             SupportActionBar.Title = viewModel.Place == null ? string.Empty : viewModel.Place.Name;
             adapter.NotifyDataSetChanged();
             SupportInvalidateOptionsMenu();
         });
     });
 }