Exemplo n.º 1
0
        public async void SetupScheduleData(SwipeRefreshLayout swipeRefresh = default)
        {
            if (viewPager.Adapter != null)
            {
                tabLayout.Visibility = viewPager.Visibility = ViewStates.Gone;
            }
            var emptyView   = FindViewById <AppCompatTextView>(Resource.Id.tv_schedule_base_emptytext);
            var tabsAdapter = new PageTabsAdapter(SupportFragmentManager);

            emptyView.Visibility = ViewStates.Visible;
            emptyView.Text       = "Loading...";
            if (swipeRefresh != null)
            {
                swipeRefresh.Refreshing = true;
            }

            var data = await WebData.GetTVSchedule().ConfigureAwait(true);

            if (data != null && data.Count > 0)
            {
                emptyView.Visibility = ViewStates.Gone;
                tabLayout.Visibility = ViewStates.Visible;
                viewPager.Visibility = ViewStates.Visible;
                viewPager.Adapter    = tabsAdapter;
                foreach (var item in data)
                {
                    tabsAdapter.AddTab(new TitleFragment()
                    {
                        Title = item.Key, Fragmnet = new MainTabs(DataEnum.DataType.TVSchedule, new List <object>(item.Value))
                    });
                }
            }
            emptyView.Text = Resources.GetString(Resource.String.empty_data_view);
            if (swipeRefresh != null)
            {
                swipeRefresh.Refreshing = false;
            }
        }