private async void LoadData(string link, SeriesDetails showData = default) { loadingView.Visibility = ViewStates.Visible; ShowData = showData is null ? await WebData.GetDetailsForTVShowSeries(link) : showData; loadingView.Visibility = ViewStates.Gone; if (ShowData != null) { if (await StorageData.IsMarkedFavorite(ShowData)) { isFavorite = true; } InvalidateOptionsMenu(); collapseToolbar.TitleEnabled = false; SupportActionBar.SetDisplayShowTitleEnabled(false); Picasso.With(this).Load(ShowData.ImageLink).Into(detailImage); collapseToolbar.Title = titleText.Text = ShowData.Title; descriptionText.Text = "Description: " + ShowData.Description; releaseText.Text = "Released: " + ShowData.ReleaseDate; genreText.Text = ShowData.Genres; seasonsHeader.Visibility = ViewStates.Visible; seasonEpisodesPager.Visibility = ViewStates.Visible; if (ShowData.Seasons != null && ShowData.Seasons.Count > 0) { var adapter = new PageTabsAdapter(SupportFragmentManager); foreach (var season in ShowData.Seasons) { adapter.AddTab(new TitleFragment() { Fragmnet = new MainTabs(DataEnum.DataType.SeasonsEpisodes, season.Episodes.Cast <object>()), Title = season.SeasonName }); } seasonsHeader.TabMode = ShowData.Seasons.Count < 5 ? TabLayout.ModeFixed : TabLayout.ModeScrollable; seasonsHeader.SetupWithViewPager(seasonEpisodesPager); seasonEpisodesPager.OffscreenPageLimit = ShowData.Seasons.Count; seasonEpisodesPager.Adapter = adapter; } else { seasonEpisodesPager.Visibility = ViewStates.Gone; seasonsHeader.Visibility = ViewStates.Gone; Error.Instance.ShowErrorSnack($"No episodes were found for {ShowData.Title}.", titleContainer); } } else { Error.Instance.ShowErrorSnack($"TV Show '{ShowData.Title}' could not be loaded.", titleContainer); } }
public async void CheckNotifcationsForFavorites() { var favList = await StorageData.GetSeriesListFromFavoritesFile(); if (favList != null && favList.Count > 0) { foreach (SeriesDetails series in favList) { if (series.NextEpisode != null) { if (await WebData.GetDetailsForTVShowSeries(series.SeriesLink) is SeriesDetails updatedSeries) { if (await StorageData.SaveSeriesToFavoritesFile(updatedSeries)) { if (updatedSeries.NextEpisode != null && updatedSeries.NextEpisode.EpisodeStreamLinks != null && updatedSeries.NextEpisode.EpisodeStreamLinks.Count > 0) { await CreateNotificationChannel(); var activityIntent = new Intent(this.ApplicationContext, typeof(EpisodeDetailActivity)); activityIntent.PutExtra("itemLink", updatedSeries.NextEpisode.EpisodeLink); var stackBuilder = TaskStackBuilder.Create(this.ApplicationContext); stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(EpisodeDetailActivity))); stackBuilder.AddNextIntent(activityIntent); var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)Android.App.PendingIntentFlags.UpdateCurrent); var builder = new NotificationCompat.Builder(this.ApplicationContext, CHANNEL_ID) .SetAutoCancel(true).SetContentIntent(resultPendingIntent) .SetContentTitle($"New Episode for {updatedSeries.Title}").SetSmallIcon(Resource.Drawable.icon) .SetContentText($"{updatedSeries.NextEpisode.EpisodeFullNameNumber}"); var notificationManager = NotificationManagerCompat.From(this.ApplicationContext); notificationManager.Notify(NOTIFICATION_ID++, builder.Build()); } } } } } } }