//Result
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                if (requestCode == 200 && resultCode == Result.Ok)
                {
                    string result = data.GetStringExtra("pageItem");

                    var item  = JsonConvert.DeserializeObject <PageClass>(result);
                    var check = MAdapter.SocialList.FirstOrDefault(a => a.PagesModelClass != null);
                    if (check != null)
                    {
                        check.PagesModelClass.PagesList.Insert(0, item);
                        MAdapter.NotifyDataSetChanged();
                    }
                    else
                    {
                        var socialSection = new SocialModelsClass
                        {
                            Id              = int.Parse(item.Id),
                            TypeView        = SocialModelType.MangedPages,
                            PagesModelClass = new PagesModelClass()
                            {
                                PagesList = new List <PageClass>()
                                {
                                    item
                                },
                            }
                        };

                        MAdapter.SocialList.Add(socialSection);
                        MAdapter.NotifyDataSetChanged();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #2
0
        private async Task GetJoinedGroups(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;

                var(apiStatus, respond) = await RequestsAsync.Group.GetJoinedGroups(UserDetails.UserId, offset, "10");

                if (apiStatus != 200 || !(respond is ListGroupsObject result) || result.Data == null)
                {
                    MainScrollEvent.IsLoading = false;
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.JoinedGroups);
                        if (checkList == null)
                        {
                            var section = new SocialModelsClass
                            {
                                Id        = 000001010101,
                                TitleHead = GetString(Resource.String.Lbl_Joined_Groups),
                                TypeView  = SocialModelType.Section
                            };
                            MAdapter.SocialList.Insert(1, section);

                            foreach (var item in from item in result.Data let check = MAdapter.SocialList.FirstOrDefault(a => a.Id == Convert.ToInt32(item.GroupId)) where check == null select item)
                            {
                                item.IsJoined = new IsJoined
                                {
                                    Bool = true
                                };

                                MAdapter.SocialList.Add(new SocialModelsClass
                                {
                                    GroupData = item,
                                    Id        = Convert.ToInt32(item.GroupId),
                                    TypeView  = SocialModelType.JoinedGroups
                                });
                            }
                        }
                        else
                        {
                            foreach (var item in from item in result.Data let check = MAdapter.SocialList.FirstOrDefault(a => a.Id == Convert.ToInt32(item.GroupId)) where check == null select item)
                            {
                                item.IsJoined = new IsJoined
                                {
                                    Bool = true
                                };

                                MAdapter.SocialList.Add(new SocialModelsClass
                                {
                                    GroupData = item,
                                    Id        = Convert.ToInt32(item.GroupId),
                                    TypeView  = SocialModelType.JoinedGroups
                                });
                            }
                        }
                    }
                    else
                    {
                        if (MAdapter.SocialList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_NoMoreGroup), ToastLength.Short)?.Show();
                        }
                    }
                }

                MainScrollEvent.IsLoading = false;
                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();
                MainScrollEvent.IsLoading = false;
            }
        }
Beispiel #3
0
        private async Task GetMyGroups()
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Group.GetMyGroups("0", "7");

                if (apiStatus != 200 || !(respond is ListGroupsObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        result.Data.Reverse();

                        var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.MangedGroups);
                        if (checkList == null)
                        {
                            var socialSection = new SocialModelsClass
                            {
                                Id = 0001111111,
                                MangedGroupsModel = new GroupsModelClass
                                {
                                    GroupsList = new List <GroupClass>(),
                                    More       = "",
                                    TitleHead  = GetString(Resource.String.Lbl_Manage_Groups)
                                },
                                TypeView = SocialModelType.MangedGroups
                            };

                            foreach (var item in from item in result.Data let check = socialSection.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item)
                            {
                                socialSection.MangedGroupsModel.GroupsList.Add(item);
                                ListUtils.MyGroupList.Add(item);
                            }

                            MAdapter.SocialList.Insert(0, socialSection);
                        }
                        else
                        {
                            foreach (var item in from item in result.Data let check = checkList.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item)
                            {
                                checkList.MangedGroupsModel.GroupsList.Add(item);
                                ListUtils.MyGroupList.Add(item);
                            }
                        }

                        await GetJoinedGroups();

                        RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                }

                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();
            }
        }
Beispiel #4
0
        //Result
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                if (requestCode == 200 && resultCode == Result.Ok)
                {
                    string result = data?.GetStringExtra("groupItem") ?? "";
                    if (!string.IsNullOrEmpty(result))
                    {
                        var item = JsonConvert.DeserializeObject <GroupClass>(result);
                        if (item == null)
                        {
                            return;
                        }

                        if (MAdapter.SocialList.Count > 0)
                        {
                            var check = MAdapter.SocialList.FirstOrDefault(a => a.TypeView == SocialModelType.MangedGroups);
                            if (check != null)
                            {
                                MAdapter?.GroupsAdapter?.GroupList?.Insert(0, item);
                                MAdapter?.GroupsAdapter?.NotifyDataSetChanged();
                                MAdapter.NotifyDataSetChanged();
                            }
                            else
                            {
                                var socialSection = new SocialModelsClass
                                {
                                    MangedGroupsModel = new GroupsModelClass
                                    {
                                        GroupsList = new List <GroupClass> {
                                            item
                                        },
                                        More      = "",
                                        TitleHead = GetString(Resource.String.Lbl_Manage_Groups)
                                    },
                                    Id       = 11111111,
                                    TypeView = SocialModelType.MangedGroups
                                };
                                MAdapter.SocialList.Insert(0, socialSection);
                                MAdapter.NotifyDataSetChanged();
                            }
                        }
                        else
                        {
                            var socialSection = new SocialModelsClass
                            {
                                MangedGroupsModel = new GroupsModelClass
                                {
                                    GroupsList = new List <GroupClass> {
                                        item
                                    },
                                    More      = "",
                                    TitleHead = GetString(Resource.String.Lbl_Manage_Groups)
                                },
                                Id       = 11111111,
                                TypeView = SocialModelType.MangedGroups
                            };
                            MAdapter.SocialList.Insert(0, socialSection);
                            MAdapter.NotifyDataSetChanged();
                        }

                        ShowEmptyPage();
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private async Task GetCommunitiesListPageApi()
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    var(apiStatus, respond) = await RequestsAsync.Global.Get_Community(UserId, "pages,liked_pages");

                    if (apiStatus != 200 || !(respond is GetCommunityObject result) || result.Pages == null)
                    {
                        Methods.DisplayReportResult(this, respond);
                    }
                    else
                    {
                        SwipeRefreshLayout.Refreshing = false;
                        var checkModel = MAdapter.SocialList.FirstOrDefault(a => a.TypeView == SocialModelType.MangedPages);

                        if (result.Pages.Count > 0)
                        {
                            if (checkModel == null)
                            {
                                var chkList = result.Pages.Where(a => a.UserId == UserDetails.UserId).ToList();
                                if (chkList.Count > 0)
                                {
                                    ListUtils.MyPageList = new ObservableCollection <PageClass>(chkList);

                                    var socialSection = new SocialModelsClass
                                    {
                                        PagesModelClass = new PagesModelClass
                                        {
                                            PagesList = new List <PageClass>(chkList),
                                            More      = "",
                                            TitleHead = GetString(Resource.String.Lbl_Manage_Pages)
                                        },
                                        Id       = 11111111,
                                        TypeView = SocialModelType.MangedPages
                                    };
                                    MAdapter.SocialList.Add(socialSection);
                                }
                            }
                        }

                        var section = new SocialModelsClass
                        {
                            Id        = 000001010101,
                            TitleHead = GetString(Resource.String.Lbl_Liked_Pages),
                            TypeView  = SocialModelType.Section
                        };

                        MAdapter.SocialList.Add(section);
                        if (result.LikedPagesList.Count > 0)
                        {
                            foreach (var page in result.LikedPagesList)
                            {
                                if (page.UserId == UserDetails.UserId)
                                {
                                    checkModel?.PagesModelClass.PagesList.Add(page);
                                }
                                else
                                {
                                    var socialSection = new SocialModelsClass
                                    {
                                        PageData = page,
                                        Id       = int.Parse(page.Id),
                                        TypeView = SocialModelType.LikedPages
                                    };
                                    page.IsLiked = "true";
                                    MAdapter.SocialList.Add(socialSection);
                                }
                            }
                        }

                        RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }

                    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();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #6
0
        private async Task GetCommunitiesListGroupApi()
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Global.Get_Community(UserId, "groups");

                if (apiStatus != 200 || !(respond is GetCommunityObject result) || result.Groups == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    if (result.Groups.Count > 0)
                    {
                        var checkModel = MAdapter.SocialList.FirstOrDefault(a => a.TypeView == SocialModelType.MangedGroups);
                        if (checkModel == null)
                        {
                            var chkList = result.Groups.Where(a => a.UserId == UserDetails.UserId).ToList();
                            if (chkList.Count > 0)
                            {
                                ListUtils.MyGroupList = new ObservableCollection <GroupClass>(chkList);

                                var socialSection = new SocialModelsClass
                                {
                                    MangedGroupsModel = new GroupsModelClass
                                    {
                                        GroupsList = new List <GroupClass>(chkList),
                                        More       = "",
                                        TitleHead  = GetString(Resource.String.Lbl_Manage_Groups)
                                    },
                                    Id       = 11111111,
                                    TypeView = SocialModelType.MangedGroups
                                };
                                MAdapter.SocialList.Add(socialSection);
                            }
                        }

                        var section = new SocialModelsClass
                        {
                            Id        = 000001010101,
                            TitleHead = GetString(Resource.String.Lbl_Joined_Groups),
                            TypeView  = SocialModelType.Section
                        };

                        MAdapter.SocialList.Add(section);

                        foreach (var group in result.Groups)
                        {
                            if (group.UserId == UserDetails.UserId)
                            {
                                checkModel?.MangedGroupsModel.GroupsList.Add(group);
                            }
                            else
                            {
                                var socialSection = new SocialModelsClass
                                {
                                    GroupData = group,
                                    Id        = int.Parse(group.GroupId),
                                    TypeView  = SocialModelType.JoinedGroups
                                };
                                group.IsJoined = "true";
                                MAdapter.SocialList.Add(socialSection);
                            }
                        }

                        RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                }

                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();
            }
        }
        private async Task GetMyGroups()
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Group.GetMyGroupsAsync("0", "7");

                if (apiStatus != 200 || respond is not ListGroupsObject result || result.Data == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    switch (respondList)
                    {
                    case > 0:
                    {
                        result.Data.Reverse();

                        var checkList = MAdapter.SocialList.FirstOrDefault(q => q.TypeView == SocialModelType.MangedGroups);
                        switch (checkList)
                        {
                        case null:
                        {
                            var socialSection = new SocialModelsClass
                            {
                                Id = 0001111111,
                                MangedGroupsModel = new GroupsModelClass
                                {
                                    GroupsList = new List <GroupClass>(),
                                    More       = "",
                                    TitleHead  = GetString(Resource.String.Lbl_Manage_Groups)
                                },
                                TypeView = SocialModelType.MangedGroups
                            };

                            foreach (var item in from item in result.Data let check = socialSection.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item)
                            {
                                socialSection.MangedGroupsModel.GroupsList.Add(item);

                                switch (ListUtils.MyGroupList.FirstOrDefault(a => a.GroupId == item.GroupId))
                                {
                                case null:
                                    ListUtils.MyGroupList.Add(item);
                                    break;
                                }
                            }

                            MAdapter.SocialList.Insert(0, socialSection);
                            break;
                        }

                        default:
                        {
                            foreach (var item in from item in result.Data let check = checkList.MangedGroupsModel.GroupsList.FirstOrDefault(a => a.GroupId == item.GroupId) where check == null select item)
                            {
                                checkList.MangedGroupsModel.GroupsList.Add(item);

                                switch (ListUtils.MyGroupList.FirstOrDefault(a => a.GroupId == item.GroupId))
                                {
                                case null:
                                    ListUtils.MyGroupList.Add(item);
                                    break;
                                }
                            }

                            break;
                        }
                        }

                        break;
                    }
                    }
                }

                await GetJoinedGroups();

                RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });

                RunOnUiThread(ShowEmptyPage);
            }
        //Result
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                switch (requestCode)
                {
                case 200 when resultCode == Result.Ok:
                {
                    string result = data?.GetStringExtra("pageItem") ?? "";
                    switch (string.IsNullOrEmpty(result))
                    {
                    case false:
                    {
                        var item = JsonConvert.DeserializeObject <PageClass>(result);
                        switch (item)
                        {
                        case null:
                            return;
                        }

                        switch (MAdapter.SocialList.Count)
                        {
                        case > 0:
                        {
                            var check = MAdapter.SocialList.FirstOrDefault(a => a.TypeView == SocialModelType.MangedPages);
                            if (check != null)
                            {
                                MAdapter.PagesAdapter?.PageList?.Insert(0, item);
                                MAdapter?.PagesAdapter?.NotifyDataSetChanged();
                                MAdapter.NotifyDataSetChanged();
                            }
                            else
                            {
                                var socialSection = new SocialModelsClass
                                {
                                    PagesModelClass = new PagesModelClass
                                    {
                                        PagesList = new List <PageClass> {
                                            item
                                        },
                                        More      = "",
                                        TitleHead = GetString(Resource.String.Lbl_Manage_Pages)
                                    },
                                    Id       = 11111111,
                                    TypeView = SocialModelType.MangedPages
                                };
                                MAdapter.SocialList.Insert(0, socialSection);
                                MAdapter.NotifyDataSetChanged();
                            }

                            break;
                        }

                        default:
                        {
                            var socialSection = new SocialModelsClass
                            {
                                PagesModelClass = new PagesModelClass
                                {
                                    PagesList = new List <PageClass> {
                                        item
                                    },
                                    More      = "",
                                    TitleHead = GetString(Resource.String.Lbl_Manage_Pages)
                                },
                                Id       = 11111111,
                                TypeView = SocialModelType.MangedPages
                            };
                            MAdapter.SocialList.Insert(0, socialSection);
                            MAdapter.NotifyDataSetChanged();
                            break;
                        }
                        }

                        break;
                    }
                    }

                    ShowEmptyPage();
                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }