예제 #1
0
        private async Task LoadPostDataAsync()
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Global.Get_Post_Data(PostId, "post_data");

                if (apiStatus == 200)
                {
                    if (respond is GetPostDataObject result)
                    {
                        var data = result.PostData;
                        if (data != null)
                        {
                            RunOnUiThread(() =>
                            {
                                try
                                {
                                    MainRecyclerView.CacheVideosFiles(Uri.Parse(data.PostFileFull));

                                    var combine = new FeedCombiner(data, MAdapter.ListDiffer, this);
                                    combine.CombineDefaultPostSections();

                                    MAdapter.NotifyDataSetChanged();
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            });

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => LoadDataComment("0")
                            });
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(this, respond);
                }

                SwipeRefreshLayout.Refreshing = false;
                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                SwipeRefreshLayout.Refreshing = false;

                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }