Example #1
0
        public void FeedData(Boolean isRefresh)
        {
            //create background thread
            Task.Run(async() =>
            {
                isLoading = true;

                if (isRefresh == true)
                {
                    pageIndex = 1;
                    mDataArray.Clear();
                    ListViewFooter.IsVisible = true;
                }
                //Background theread
                UserBean userbean = new UserBean();
                userbean.Username = "******";
                userbean.Password = "******";
                var result        = await JsonService.CallPost(userbean, pageIndex++, pageSize);
                string title      = result.youtubes[0].title;
                Debug.WriteLine("title:" + title);

                Device.BeginInvokeOnMainThread(() =>
                {
                    if (result.youtubes.Count < pageSize)
                    {
                        ListViewFooter.IsVisible = false;
                    }
                    // Main Thread (UI) โปรแกรมจะทำต่อเมื่อว่างงาน
                    //listView.ItemsSource = result.youtubes; การเรียกใช้แบบ hard code

                    listView.EndRefresh();
                    mDataArray.AddRage(result.youtubes);
                    isLoading = false;
                });
            });
        }