public void GetNewsData() { Task.Run(async() => { LoginResponse loginResponse = PingPongNews.Login(); ListCategoriesResponse categoriesResponse = await PingPongNews.GetListCategories(1, 10); Device.BeginInvokeOnMainThread(() => { if (categoriesResponse != null && categoriesResponse.success) { var Categories = categoriesResponse.data.categories; if (Categories.Count > 0) { foreach (var item in Categories) { this.Children.Add(new ItemNewsPage(item) { Title = item.name }); } } } }); }); }
private void CreateTabCategories() { Task.Run(async() => { LoginResponse loginResponse = PingPongNews.Login(); ListCategoriesResponse categoriesResponse = await PingPongNews.GetListCategories(1, 10); //var ListCategoriesResponse = await GetListCategories(); Device.BeginInvokeOnMainThread(() => { if (categoriesResponse.success) { var Categories = categoriesResponse.data.categories; foreach (var category in Categories) { Children.Add(new CategoryTab(category)); } } else { Debug.WriteLine("List Categories can't get"); } }); }); }
public async Task GetData() { Debug.WriteLine("ThreadId: " + Thread.CurrentThread.ManagedThreadId.ToString()); LoginResponse loginResponse = PingPongNews.Login(); ListCategoriesResponse categoriesResponse = await PingPongNews.GetListCategories(1, 10); Device.BeginInvokeOnMainThread(() => { if (categoriesResponse != null && categoriesResponse.success) { var Categories = categoriesResponse.data.categories; if (Categories.Count > 0) { foreach (var item in Categories) { this.Children.Add(new ItemNewsPage(item)); } } } }); }