예제 #1
0
        private async void LoadDataForType()
        {
            switch (tabType)
            {
            case DataEnum.DataType.NewEpisodes:
            case DataEnum.DataType.NewPopularEpisodes:
            case DataEnum.DataType.PopularShows:
                var mainAdapter = new EpisodesAdapter <EpisodeList>(tabType, emptyView, refreshView);
                recyclerView.SetAdapter(mainAdapter);
                mainAdapter.ItemClick += (s, e) =>
                {
                    AppView.HandleItemShowEpisodeClick(mainAdapter.GetItem(e), Activity);
                };
                break;

            case DataEnum.DataType.TVSchedule:
                var scheduleAdapter = new EpisodesAdapter <CalenderScheduleList>(new List <CalenderScheduleList>(items.Cast <CalenderScheduleList>()), tabType, emptyView);
                recyclerView.SetAdapter(scheduleAdapter);
                scheduleAdapter.ItemClick += (s, e) =>
                {
                    AppView.HandleItemShowEpisodeClick(scheduleAdapter.GetItem(e), Activity);
                };
                break;

            case DataEnum.DataType.Genres:
                EpisodesAdapter <GenresShow> genresAdapter = null;
                if (genresType == DataEnum.GenreDataType.LatestEpisodes)
                {
                    genresAdapter = new EpisodesAdapter <GenresShow>(tabType, emptyView, refreshView);
                }
                else if (genresType == DataEnum.GenreDataType.PopularEpisodes)
                {
                    genresAdapter = new EpisodesAdapter <GenresShow>(tabType, emptyView, refreshView);
                }
                else if (genresType == DataEnum.GenreDataType.Shows)
                {
                    if (refreshView != null)
                    {
                        refreshView.Refreshing = true;
                    }
                    var genreList = await WebData.GetGenresShows(genre, genrePage ++, year);

                    if (refreshView != null)
                    {
                        refreshView.Refreshing = false;
                    }
                    genresAdapter = new EpisodesAdapter <GenresShow>(genreList, tabType, emptyView);
                    var scrollListener = new EndlessScroll(layoutManager);
                    scrollListener.LoadMoreTask += async delegate
                    {
                        refreshView.Refreshing = true;
                        var items = await WebData.GetGenresShows(genre, genrePage ++, year);

                        if (items != null)
                        {
                            genresAdapter.AddItem(items.ToArray());
                        }
                        refreshView.Refreshing = false;
                    };
                    recyclerView.AddOnScrollListener(scrollListener);
                }
                recyclerView.SetAdapter(genresAdapter);
                genresAdapter.ItemClick += (s, e) =>
                {
                    AppView.HandleItemShowEpisodeClick(genresAdapter.GetItem(e), Activity);
                };
                break;

            case DataEnum.DataType.SeasonsEpisodes:
                if (refreshView != null)
                {
                    refreshView.Refreshing = true;
                }
                var seasonsEpisodesAdapter = new EpisodesAdapter <ShowEpisodeDetails>(new List <ShowEpisodeDetails>(items.Cast <ShowEpisodeDetails>()), tabType, emptyView);
                recyclerView.SetAdapter(seasonsEpisodesAdapter);
                if (refreshView != null)
                {
                    refreshView.Refreshing = false;
                }
                seasonsEpisodesAdapter.ItemClick += (s, e) =>
                {
                    AppView.HandleItemShowEpisodeClick(seasonsEpisodesAdapter.GetItem(e), Activity);
                };
                break;

            case DataEnum.DataType.UserFavorites:
                var favsAdapter = new EpisodesAdapter <SeriesDetails>(tabType, emptyView, refreshView);
                recyclerView.SetAdapter(favsAdapter);
                favsAdapter.ItemClick += (s, e) =>
                {
                    AppView.HandleItemShowEpisodeClick(favsAdapter.GetItem(e), Activity);
                };
                break;

            default:
                break;
            }
        }