public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var viewHolder = holder as MovieCategoryViewHolder; var thisCategory = this.categories [position]; viewHolder.CategoryName.Text = thisCategory.CategoryName; if (viewHolder.MovieList.GetLayoutManager () == null) { var movieLayoutManager = new LinearLayoutManager (context, LinearLayoutManager.Horizontal, false); viewHolder.MovieList.SetLayoutManager (movieLayoutManager); } var adapter = viewHolder.MovieList.GetAdapter() as MovieRecyclerViewAdapter; if (adapter == null) { var movieAdapter = new MovieRecyclerViewAdapter (this, this.context, thisCategory.Movies, this.configuration); viewHolder.MovieList.SetAdapter (movieAdapter); } else { adapter.Reload (thisCategory.Movies); } }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var viewHolder = holder as MovieCategoryViewHolder; var thisCategory = this.categories [position]; viewHolder.CategoryName.Text = thisCategory.CategoryName; // If the view holder is being reused, the layout manager will have already been set if (viewHolder.MovieList.GetLayoutManager () == null) viewHolder.MovieList.SetLayoutManager (new LinearLayoutManager (context, LinearLayoutManager.Horizontal, false)); // If the view holder is being reused, the adapter will have already been set // Is a reload necessary? Theory is the view holder being bound may not be // at the same position and so the data might be out of symcmight be out of syn var adapter = viewHolder.MovieList.GetAdapter() as MovieRecyclerViewAdapter; if (adapter == null) { var movieAdapter = new MovieRecyclerViewAdapter (this.context, thisCategory.Movies, this.configuration, position == this.favoritesCategoryIndex); viewHolder.MovieList.SetAdapter (movieAdapter); } else { Console.WriteLine ("MovieCategoryRecyclerViewAdapter.OnBindViewHolder MovieList adapter != null"); // adapter.Reload (thisCategory.Movies); } }
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") this.btnPlay.Alpha = 1; // this.btnPlay.StartAnimation (new AlphaAnimation (this.btnPlay.Alpha, 1.0f) { Duration = 300, FillAfter = true }); else this.btnPlay.Alpha = 0; // this.btnPlay.StartAnimation (new AlphaAnimation (this.btnPlay.Alpha, 0.0f) { Duration = 300, FillAfter = true }); } var similarMoviesResponse = await Data.Current.GetSimilarForMovieAsync (this.movieDetail.Id); if (similarMoviesResponse != null && similarMoviesResponse.Results != null) { this.similarMovies = similarMoviesResponse.Results; if (similarMoviesResponse.Results.Count == 0) this.vwSimilarMovies.Alpha = 0; // this.vwSimilarMovies.StartAnimation (new AlphaAnimation (vwSimilarMovies.Alpha, 0.0f) { Duration = 300, FillAfter = true }); else { var orientation = this.Resources.Configuration.Orientation; //.getResources().getConfiguration().orientation this.movieList.SetLayoutManager (new LinearLayoutManager (this, orientation == Android.Content.Res.Orientation.Portrait ? LinearLayoutManager.Horizontal : LinearLayoutManager.Vertical, false)); if (orientation == Android.Content.Res.Orientation.Landscape) this.vwSimilarMovies.SetBackgroundColor (Android.Graphics.Color.Argb (20, 0, 0, 0)); else this.vwSimilarMovies.SetBackgroundColor (Android.Graphics.Color.Argb (0, 0, 0, 0)); if (this.movieAdapter == null) { this.movieAdapter = new MovieRecyclerViewAdapter (this, this.similarMovies, this.configuration, false); this.movieList.SetAdapter (this.movieAdapter); } this.vwSimilarMovies.Alpha = 1; // this.vwSimilarMovies.StartAnimation (new AlphaAnimation (this.vwSimilarMovies.Alpha, 1.0f) { Duration = 300, FillAfter = true }); } } this.txtTitle.Text = this.movieDetail.Title; this.txtReleaseDate.Text = String.Format ("Release Date: {0}", this.movieDetail.ReleaseDate.ToShortDateString ()); this.ratingBar.NumStars = 5; this.ratingBar.Rating = (float) this.movieDetail.VoteAverage / 2; this.txtVoteCount.Text = String.Format ("(from {0} votes)", this.movieDetail.VoteCount.ToString ()); this.txtOverview.Text = this.movieDetail.Overview; ImageLoader.Instance.DisplayImage (String.Concat (this.configuration.Images.BaseUrl, this.configuration.Images.PosterSizes [1], this.movieDetail.PosterPath), this.imgPoster); this.startPulseBackground (); this.updateSaveButtonState (); } }
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") this.btnPlay.Alpha = 1; // this.btnPlay.StartAnimation (new AlphaAnimation (this.btnPlay.Alpha, 1.0f) { Duration = 300, FillAfter = true }); else this.btnPlay.Alpha = 0; // this.btnPlay.StartAnimation (new AlphaAnimation (this.btnPlay.Alpha, 0.0f) { Duration = 300, FillAfter = true }); } var similarMoviesResponse = await Data.Current.GetSimilarForMovieAsync (this.movieDetail.Id); if (similarMoviesResponse != null && similarMoviesResponse.Results != null) { this.similarMovies = similarMoviesResponse.Results; if (similarMoviesResponse.Results.Count == 0) this.vwSimilarMovies.Alpha = 0; // this.vwSimilarMovies.StartAnimation (new AlphaAnimation (vwSimilarMovies.Alpha, 0.0f) { Duration = 300, FillAfter = true }); else { if (this.movieAdapter == null) { this.movieAdapter = new MovieRecyclerViewAdapter (this, this, this.similarMovies, this.configuration); this.movieList.SetAdapter (this.movieAdapter); } else { this.movieAdapter.Reload (this.similarMovies); } this.vwSimilarMovies.Alpha = 1; // this.vwSimilarMovies.StartAnimation (new AlphaAnimation (this.vwSimilarMovies.Alpha, 1.0f) { Duration = 300, FillAfter = true }); } } this.txtTitle.Text = this.movieDetail.Title; this.txtReleaseDate.Text = String.Format ("Release Date: {0}", this.movieDetail.ReleaseDate.ToShortDateString ()); this.ratingBar.NumStars = 5; this.ratingBar.Rating = (float) this.movieDetail.VoteAverage / 2; this.txtVoteCount.Text = String.Format ("(from {0} votes)", this.movieDetail.VoteCount.ToString ()); this.txtOverview.Text = this.movieDetail.Overview; ImageLoader.Instance.DisplayImage (String.Concat (this.configuration.Images.BaseUrl, this.configuration.Images.PosterSizes [1], this.movieDetail.PosterPath), this.imgPoster); this.startPulseBackground (); this.updateSaveButtonState (); } }