private void Bind() { overview.Text = viewModel.Overview; originalTitle.Text = viewModel.OriginalTitle; releaseDate.Text = viewModel.ReleaseDate; rating.Rating = viewModel.Rating; votes.Text = viewModel.Votes; favorite.Text = viewModel.FavoriteButtonText; similarManager = new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false); similar.SetLayoutManager(similarManager); similarAdapter = new ItemAdapter(viewModel.GetCachedItems()); similar.SetAdapter(similarAdapter); var similarScrollListener = new ItemAdapterScollListener(similarManager); similarScrollListener.LoadMore += async delegate() { if (!viewModel.CanLoadMoreSimilar()) { return; } await viewModel.GetSimilar().ConfigureAwait(false); }; similar.AddOnScrollListener(similarScrollListener); favorite.Click += delegate { //quick and dirty, need to use canexecute on command if (uiBusy) { return; } uiBusy = true; viewModel.ToggleFavorite(); uiBusy = false; }; play.Click += delegate { if (uiBusy) { return; } uiBusy = true; viewModel.PlayVideo(); uiBusy = false; }; Task.Run(async() => { var url = await Locator.Get <IApiService>().GetImageUrl(viewModel.PosterPath).ConfigureAwait(false); var bitmap = Locator.Get <IImageService>().LoadImage(url); Locator.Get <IUIDispatcher>().RunOnUiThread(() => { poster.SetImageBitmap(bitmap); bitmap.Dispose(); bitmap = null; }); }); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); viewModel = Locator.GetNewInstance <DetailViewModel>(); viewModel.PropertyChanged += ViewModel_PropertyChanged; viewModel.Initialize(Locator.Get <INavigationService>().GetCurrentItem()); Task.Run(async() => { await viewModel.GetSimilar().ConfigureAwait(false); await viewModel.GetVideos().ConfigureAwait(false); }); Activity.InvalidateOptionsMenu(); }