public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) { this.category = data; this.configuration = configuration; this.selectionAction = selectionAction; this.lblCategoryName.Text = this.category.CategoryName; this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; Data.Current.FavoriteChanged += this.favoriteChanged; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies); var indexPath = this.cvMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true, true); } else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) { cell.SetHighlighted (false, true, () => { var movie = this.category.Movies [indexPath.Row]; Data.Current.ToggleFavorite (movie); }); } } else { foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvMovies.AddGestureRecognizer (this.longPressRecognizer); this.cvMovies.Source = this.collectionViewSource; this.cvMovies.ReloadData (); }
public override void PrepareForReuse () { if (this.collectionViewSource != null) this.collectionViewSource.MovieSelected -= this.collectionViewSource_MovieSelected; this.collectionViewSource = null; this.category = null; this.configuration = null; this.selectionAction = null; this.cvMovies.RemoveGestureRecognizer (this.longPressRecognizer); this.longPressRecognizer = null; base.PrepareForReuse (); }
public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) { this.category = data; this.configuration = configuration; this.selectionAction = selectionAction; this.lblCategoryName.Text = this.category.CategoryName; this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies); var indexPath = this.cvMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true); } else { if (this.longPressRecognizer.State != UIGestureRecognizerState.Ended) return; var movie = this.category.Movies [indexPath.Row]; if (Data.Current.IsInFavorites (movie)) Data.Current.RemoveFromFavorites (movie); else Data.Current.AddToFavorites (movie); cell.SetHighlighted (false); NSNotificationCenter.DefaultCenter.PostNotificationName ("FavoriteListChanged", this); } } else { foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvMovies.AddGestureRecognizer (this.longPressRecognizer); this.cvMovies.Source = this.collectionViewSource; this.cvMovies.ReloadData (); }
private async void updateLayout () { this.btnPlay.Alpha = 0; this.vwSimilarMovies.Alpha = 0; if (this.MovieDetail != null) { var videoResponse = await Data.Current.GetVideosForMovieAsync (this.MovieDetail.Id); if (videoResponse != null && videoResponse.Results != null) { this.videos = videoResponse.Results; if (videoResponse.Results.Count > 0 && videoResponse.Results [0].Site.ToLower () == "youtube") UIView.Animate (0.3f, () => this.btnPlay.Alpha = 1.0f); else UIView.Animate (0.3f, () => this.btnPlay.Alpha = 0.0f); } var similarMoviesResponse = await Data.Current.GetSimilarForMovieAsync (this.MovieDetail.Id); if (similarMoviesResponse != null && similarMoviesResponse.Results != null) { this.similarMovies = similarMoviesResponse.Results; if (similarMoviesResponse.Results.Count == 0) UIView.Animate(0.3f, () => this.vwSimilarMovies.Alpha = 0.0f); else { if (this.collectionViewSource == null) { this.collectionViewSource = new MovieCollectionViewSource (this.similarMovies, this.Configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; this.cvSimilarMovies.Source = this.collectionViewSource; this.cvSimilarMovies.ReloadData (); } else { this.collectionViewSource.Reload (this.similarMovies); this.cvSimilarMovies.ReloadData (); } this.updateSimilarMoviesLayout (); UIView.Animate(0.3f, () => this.vwSimilarMovies.Alpha = 1.0f); } } this.lblTitle.Text = this.MovieDetail.Title; this.lblReleaseDate.Text = String.Format ("Release Date: {0}", this.MovieDetail.ReleaseDate.ToShortDateString ()); var ratingConfig = new RatingConfig(UIImage.FromBundle("star_empty"), UIImage.FromBundle("star_filled"), UIImage.FromBundle("star_filled")); var averageRating = (decimal)this.MovieDetail.VoteAverage / 2; this.ratingView = new PDRatingView (new CGRect(0f, 0f, this.vwVoteAverageContainer.Frame.Width, this.vwVoteAverageContainer.Frame.Height), ratingConfig, averageRating); this.vwVoteAverageContainer.Add(this.ratingView); this.lblVoteCount.Text = String.Format ("(from {0} votes)", this.MovieDetail.VoteCount.ToString ()); this.tvOverview.Text = this.MovieDetail.Overview; this.tvOverviewHeightConstraint.Constant = this.tvOverview.SizeThatFits (new CGSize (this.tvOverview.Frame.Width, float.MaxValue)).Height; var posterUri = new Uri (String.Concat (this.Configuration.Images.BaseUrl, this.Configuration.Images.PosterSizes[1], this.MovieDetail.PosterPath)); this.imgPoster.Image = ImageLoader.DefaultRequestImage (posterUri, this); this.btnBack.Hidden = this.NavigationController.ViewControllers.Length < 3; this.startPulseBackground (); this.updateSaveButtonState (); } }
private async void willAppear() { this.configuration = await Data.Current.GetConfigurationAsync (); this.categories = await Data.Current.GetMoviesByCategoryAsync (); this.spotlight = await Data.Current.GetSpotlightMoviesAsync (); if (this.tableViewSource == null) { this.tableViewSource = new MovieCategoryTableViewSource (this.configuration, this.categories); this.tableViewSource.MovieSelected += this.source_MovieSelected; this.tblMovieCategories.Source = this.tableViewSource; } else { this.tableViewSource.Reload (this.categories); } this.tblMovieCategories.ReloadData (); if (this.spotlightSource == null) { this.spotlightSource = new MovieCollectionViewSource (this.spotlight, this.configuration); this.spotlightSource.MovieSelected += this.source_MovieSelected; this.cvSpotlight.Source = this.spotlightSource; } else { this.spotlightSource.Reload (this.spotlight); } this.tblMovieCategoriesHeightConstraint.Constant = this.tblMovieCategories.ContentSize.Height; this.updateSpotlightItemSize (); this.cvSpotlight.ReloadData (); }