void CreateLayout() { _noDataView = new NoDataView("ic_cloud_off_48pt", "No Data Found") { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; _loadingDataView = new LoadingDataView { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; _arrowImage = new Image { Source = "ic_arrow_downward" }; _pullText = new Label() { Text = "Pull To Refresh", FontSize = 15, TextColor = Color.Black, HorizontalTextAlignment = TextAlignment.Center }; _pullToRefreshLayout = new StackLayout { VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, Spacing = 5, Padding = new Thickness(0, 5, 0, 0), Children = { _arrowImage, _pullText } }; _mainNoDataLayout = new ListView { SeparatorVisibility = SeparatorVisibility.None, IsPullToRefreshEnabled = true, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Header = new StackLayout { Spacing = 200, Children = { _pullToRefreshLayout, _noDataView } } }; if (Device.OS == TargetPlatform.iOS) { var isfavorite = League.IsFavorite; _addItem = new ToolbarItem(); _addItem.Text = isfavorite ? "remove" : "add"; _addItem.Clicked += _addItem_Clicked; _addItem.Icon = isfavorite ? "ic_favorite_white" : "ic_favorite_border_white"; ToolbarItems.Add(_addItem); } _fixturesListView = new ListView(ListViewCachingStrategy.RecycleElement) { RowHeight = 120, IsPullToRefreshEnabled = true, BackgroundColor = Color.White, ItemTemplate = new DataTemplate(typeof(FixtureLayout)), SeparatorVisibility = SeparatorVisibility.None, Opacity = 0 }; }
async Task LoadFixtures() { Device.BeginInvokeOnMainThread(async() => { if (_loadingDataView == null) { _loadingDataView = new LoadingDataView { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, }; if (Device.OS == TargetPlatform.iOS) { _loadingDataView.Opacity = 0; } } if (Device.OS == TargetPlatform.Android) { DroidLayout(new StackLayout { Opacity = 0, Children = { _loadingDataView } }); } else { Content = _loadingDataView; await Content.FadeTo(1, (uint)Integers.AnimationSpeed, Easing.SinIn); } if (_loadingDataView != null) { _loadingDataView.RotateImage(); } }); PauseAutoUpdate(); var result = await ScoresApp.Service.WebService.Default.GetLeagueMatches(League.Id, true, cts); _fixturesListView.ItemsSource = result; StartAutoUpdate(); Device.BeginInvokeOnMainThread(async() => { _fixturesListView.EndRefresh(); _mainNoDataLayout.EndRefresh(); if (result.Count > 0) { if (Device.OS == TargetPlatform.Android) { DroidLayout(_fixturesListView); } else { await Content.FadeTo(0, (uint)Integers.AnimationSpeed, Easing.SinOut); Content = _fixturesListView; await Content.FadeTo(1, (uint)Integers.AnimationSpeed, Easing.SinIn); } } else { if (Device.OS == TargetPlatform.Android) { DroidLayout(_mainNoDataLayout); } else { await Content.FadeTo(0, (uint)Integers.AnimationSpeed, Easing.SinOut); Content = _mainNoDataLayout; await Content.FadeTo(1, (uint)Integers.AnimationSpeed, Easing.SinIn); } } _loadingDataView = null; }); }