protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Set our view from the "main" layout resource this.SetContentView (Resource.Layout.movie_detail); // Create your application here var strConfig = this.Intent.Extras.GetString ("Configuration"); var strSelectedMovie = this.Intent.Extras.GetString ("SelectedMovie"); this.configuration = JsonConvert.DeserializeObject<ConfigurationResponse> (strConfig); this.movieDetail = JsonConvert.DeserializeObject<Movie> (strSelectedMovie); this.btnPlay = this.FindViewById<Button> (Resource.Id.movie_detail_btnPlay); this.btnPlay.Click += this.btnPlay_Click; this.btnFavorite = this.FindViewById<Button> (Resource.Id.movie_detail_btnFavorite); this.btnFavorite.Click += this.btnFavorite_Click; this.btnClose = this.FindViewById<ImageButton> (Resource.Id.movie_detail_close); this.btnClose.Click += this.btnClose_Click; this.txtTitle = this.FindViewById<TextView> (Resource.Id.movie_detail_txtTitle); this.txtReleaseDate = this.FindViewById<TextView> (Resource.Id.movie_detail_txtReleaseDate); this.ratingBar = this.FindViewById<RatingBar> (Resource.Id.movie_detail_ratingBar); this.txtVoteCount = this.FindViewById<TextView> (Resource.Id.movie_detail_txtVoteCount); this.txtOverview = this.FindViewById<TextView> (Resource.Id.movie_detail_txtOverview); this.imgPoster = this.FindViewById<ImageView> (Resource.Id.movie_detail_imgPoster); this.vwSimilarMovies = this.FindViewById<RelativeLayout> (Resource.Id.movie_detail_vwSimilarMovies); this.movieList = this.FindViewById<RecyclerView>(Resource.Id.movie_detail_lstSimilarMovies); this.movieLayoutManager = new LinearLayoutManager (this, LinearLayoutManager.Horizontal, false); this.movieList.SetLayoutManager (this.movieLayoutManager); this.updateLayout (); }
public void Bind (Movie movie, ConfigurationResponse configuration) { this.data = movie; this.configuration = configuration; this.vwFavoriteIndicator.Hidden = !Data.Current.IsInFavorites (this.data); var imageUri = new Uri (String.Concat (this.configuration.Images.BaseUrl, this.configuration.Images.PosterSizes [0], this.data.PosterPath)); this.imgPoster.Image = ImageLoader.DefaultRequestImage (imageUri, this); }
public override void PrepareForReuse () { this.data = null; this.configuration = null; this.SetHighlighted (false, false); this.Selected = false; base.PrepareForReuse (); }
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 (); }
private async void create (Bundle savedInstanceState) { // Set our view from the "main" layout resource this.SetContentView (Resource.Layout.movie_browse); this.categoryList = FindViewById<RecyclerView>(Resource.Id.movie_category_recyclerView); this.configuration = await Data.Current.GetConfigurationAsync (); this.categories = await Data.Current.GetMoviesByCategoryAsync (); this.categoryLayoutManager = new LinearLayoutManager (this, LinearLayoutManager.Vertical, false); this.categoryList.SetLayoutManager (this.categoryLayoutManager); if (this.categoryList.GetAdapter () == null) { this.categoryAdapter = new MovieCategoryRecyclerViewAdapter (this, this.categories, this.configuration); this.categoryList.SetAdapter (this.categoryAdapter); } else { this.categoryAdapter.Reload (this.categories); } }
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 willAppear() { if (this.tableViewSource != null) this.tableViewSource.MovieSelected += this.tableViewSource_MovieSelected; if (this.favoritesChangedNotification == null) { this.favoritesChangedNotification = NSNotificationCenter.DefaultCenter.AddObserver (new NSString ("FavoriteListChanged"), (notification) => { this.tblMovieCategories.ReloadData(); }); } this.configuration = await Data.Current.GetConfigurationAsync (); this.data = await Data.Current.GetMoviesByCategoryAsync (); if (this.tableViewSource == null) { this.tableViewSource = new MovieCategoryTableViewSource (this.configuration, this.data); this.tableViewSource.MovieSelected += this.tableViewSource_MovieSelected; this.tblMovieCategories.Source = this.tableViewSource; this.tblMovieCategories.ReloadData (); } else { this.tableViewSource.Reload (this.data); this.tblMovieCategories.ReloadData (); } }
public MovieCollectionViewSource (List<Movie> movies, ConfigurationResponse configuration) { this.movies = movies; this.configuration = configuration; }
public Task<ConfigurationResponse> GetConfigurationAsync () { var tcs = new TaskCompletionSource<ConfigurationResponse> (); Task.Factory.StartNew (async () => { var urlString = String.Format (StringResources.GetConfigurationUriFormatString, StringResources.ApiKey); var cacheKey = this.getCacheKey (urlString); if (this.configuration != null) { tcs.TrySetResult (this.configuration); } else { if (cache.ContainsKey(cacheKey)) { var response = cache.Get<ConfigurationResponse>(cacheKey); this.configuration = response; tcs.TrySetResult (this.configuration); } else { var client = this.httpClientFactory.Create (); var response = await client.GetAsync (urlString); var json = await response.Content.ReadAsStringAsync (); var result = JsonConvert.DeserializeObject<ConfigurationResponse> (json); this.configuration = result; cache.Set<ConfigurationResponse> (cacheKey, this.configuration); tcs.TrySetResult (this.configuration); } } }); return tcs.Task; }
public MovieCategoryRecyclerViewAdapter(Activity context, List<MovieCategory> items, ConfigurationResponse configuration) : base() { this.context = context; this.configuration = configuration; this.categories = items; }
public MovieCategoryTableViewSource (ConfigurationResponse configuration, List<MovieCategory> categories) { this.configuration = configuration; this.categories = categories; }
public MovieRecyclerViewAdapter(INotifyDataSetChangedReceiver receiver, Activity context, List<Movie> items, ConfigurationResponse configuration) : base() { this.receiver = receiver; this.context = context; this.configuration = configuration; this.movies = items; }