Example #1
0
        private async Task LoadMemories(string type = "all")
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Posts.FetchMemoriesPost(type);

                if (apiStatus.Equals(200))
                {
                    if (respond is FetchMemoriesObject result)
                    {
                        var respondListFriends = result.Data.Friends.Count;
                        if (respondListFriends > 0)
                        {
                            LoadFriendsLayout(result.Data.Friends, Methods.FunString.FormatPriceValue(result.Data.Friends.Count));
                        }

                        if (result.Data.Posts.Count > 0)
                        {
                            var time    = Methods.Time.TimeAgo(int.Parse(result.Data.Posts.FirstOrDefault()?.Time ?? "0"));
                            var section = new AdapterModelsClass
                            {
                                Id         = 000001010101,
                                AboutModel = new AboutModelClass()
                                {
                                    TitleHead = GetText(Resource.String.Lbl_Post) + " " + time
                                },
                                TypeView = PostModelType.Section
                            };

                            PostFeedAdapter.ListDiffer.Add(section);
                            PostFeedAdapter.NotifyDataSetChanged();
                        }

                        MainRecyclerView.LoadMemoriesDataApi(apiStatus, respond, PostFeedAdapter.ListDiffer);
                    }
                }
                else
                {
                    Methods.DisplayReportResult(this, respond);
                }

                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                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();
            }
        }