示例#1
0
        private void InitGUIElements(View view)
        {
            rwGroups = view.FindViewById <RecyclerView>(Resource.Id.rw_groups);

            rwGroups.HasFixedSize = true;
            var layoutManager = new LinearLayoutManager(view.Context, LinearLayoutManager.Vertical, false);

            rwGroups.SetLayoutManager(layoutManager);

            adapter = new UserGroupsAdapter(Instance.UserGroups.Groups);
            rwGroups.SetAdapter(adapter);
        }
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                var item = SocialList[viewHolder.AdapterPosition];
                if (item != null)
                {
                    switch (item.TypeView)
                    {
                    case SocialModelType.MangedGroups:
                    {
                        switch (viewHolder)
                        {
                        case AdapterHolders.GroupsSocialViewHolder holder:
                        {
                            switch (GroupsAdapter)
                            {
                            case null:
                                holder.GroupsRecyclerView?.SetLayoutManager(new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false));
                                GroupsAdapter = new UserGroupsAdapter(ActivityContext)
                                {
                                    GroupList = new ObservableCollection <GroupClass>()
                                };
                                holder.GroupsRecyclerView?.SetAdapter(GroupsAdapter);
                                GroupsAdapter.ItemClick += GroupsAdapterOnItemClick;
                                break;
                            }

                            var countList = item.MangedGroupsModel.GroupsList.Count;
                            switch (item.MangedGroupsModel.GroupsList.Count)
                            {
                            case > 0 when countList > 0:
                            {
                                foreach (var user in from user in item.MangedGroupsModel.GroupsList let check = GroupsAdapter.GroupList.FirstOrDefault(a => a.GroupId == user.GroupId) where check == null select user)
                                {
                                    GroupsAdapter.GroupList.Add(user);
                                }

                                GroupsAdapter.NotifyItemRangeInserted(countList - 1, GroupsAdapter.GroupList.Count - countList);
                                break;
                            }

                            case > 0:
                                GroupsAdapter.GroupList = new ObservableCollection <GroupClass>(item.MangedGroupsModel.GroupsList);
                                GroupsAdapter.NotifyDataSetChanged();
                                break;
                            }

                            holder.AboutHead.Text       = item.MangedGroupsModel?.TitleHead;
                            holder.AboutMore.Text       = item.MangedGroupsModel?.More;
                            holder.AboutMore.Visibility = GroupsAdapter?.GroupList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible;
                            break;
                        }
                        }

                        break;
                    }

                    case SocialModelType.JoinedGroups:
                    {
                        switch (viewHolder)
                        {
                        case GroupsAdapterViewHolder holder:
                        {
                            var options = new RequestOptions();
                            options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(110)));
                            options.Error(Resource.Drawable.ImagePlacholder).Placeholder(Resource.Drawable.ImagePlacholder);

                            GlideImageLoader.LoadImage(ActivityContext, item.GroupData.Avatar, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable, false, options);

                            holder.Name.Text = Methods.FunString.DecodeString(item.GroupData.Name);

                            if (WoWonderTools.IsJoinedGroup(item.GroupData))
                            {
                                holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Joined);
                                holder.JoinButton.Tag  = "true";
                            }
                            else
                            {
                                holder.JoinButton.Text = ActivityContext.GetString(Resource.String.Btn_Join_Group);
                                holder.JoinButton.Tag  = "false";
                            }

                            break;
                        }
                        }

                        break;
                    }

                    case SocialModelType.Section:
                    {
                        if (viewHolder is not AdapterHolders.SectionViewHolder holder)
                        {
                            return;
                        }

                        holder.AboutHead.Text = item.TitleHead;
                        break;
                    }

                    case SocialModelType.MangedPages:
                    {
                        switch (viewHolder)
                        {
                        case AdapterHolders.PagesSocialViewHolder holder:
                        {
                            switch (PagesAdapter)
                            {
                            case null:
                                holder.PagesRecyclerView?.SetLayoutManager(new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false));
                                PagesAdapter = new UserPagesAdapter(ActivityContext)
                                {
                                    PageList = new ObservableCollection <PageClass>()
                                };
                                holder.PagesRecyclerView?.SetAdapter(PagesAdapter);
                                PagesAdapter.ItemClick += PagesAdapterOnItemClick;
                                break;
                            }

                            var countList = item.PagesModelClass.PagesList.Count;
                            switch (item.PagesModelClass.PagesList.Count)
                            {
                            case > 0 when countList > 0:
                            {
                                foreach (var user in from user in item.PagesModelClass.PagesList let check = PagesAdapter.PageList.FirstOrDefault(a => a.PageId == user.PageId) where check == null select user)
                                {
                                    PagesAdapter.PageList.Add(user);
                                }

                                PagesAdapter.NotifyItemRangeInserted(countList - 1, PagesAdapter.PageList.Count - countList);
                                break;
                            }

                            case > 0:
                                PagesAdapter.PageList = new ObservableCollection <PageClass>(item.PagesModelClass.PagesList);
                                PagesAdapter.NotifyDataSetChanged();
                                break;
                            }

                            holder.AboutHead.Text       = item.PagesModelClass?.TitleHead;
                            holder.AboutMore.Text       = item.PagesModelClass?.More;
                            holder.AboutMore.Visibility = PagesAdapter?.PageList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible;
                            break;
                        }
                        }

                        break;
                    }

                    case SocialModelType.LikedPages:
                    {
                        switch (viewHolder)
                        {
                        case PageAdapterViewHolder holder:
                        {
                            GlideImageLoader.LoadImage(ActivityContext, item.PageData.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                            holder.About.Text = item.PageData.Category;

                            if (!string.IsNullOrEmpty(item.PageData.PageTitle) || !string.IsNullOrWhiteSpace(item.PageData.PageTitle))
                            {
                                holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageTitle), 20);
                            }
                            else
                            {
                                holder.Name.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.PageData.PageName), 20);
                            }

                            //Set style Btn Like page
                            if (WoWonderTools.IsLikedPage(item.PageData))
                            {
                                holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                                holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                                holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Unlike);
                                holder.Button.Tag  = "true";
                            }
                            else
                            {
                                holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                                holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                                holder.Button.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                                holder.Button.Tag  = "false";
                            }

                            break;
                        }
                        }

                        break;
                    }

                    case SocialModelType.Pages:
                        break;

                    case SocialModelType.Groups:
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                // Check if we're running on Android 5.0 or higher
                if ((int)Build.VERSION.SdkInt < 23)
                {
                }
                else
                {
                    Window.AddFlags(WindowManagerFlags.TranslucentNavigation);
                }

                base.OnCreate(savedInstanceState);

                IMethods.IApp.FullScreenApp(this);

                var view = MyContextWrapper.GetContentView(this, Settings.Lang, Resource.Layout.Groups_Layout);
                if (view != null)
                {
                    SetContentView(view);
                }
                else
                {
                    SetContentView(Resource.Layout.Groups_Layout);
                }

                var groupsType = Intent.GetStringExtra("GroupsType") ?? "Data not available";
                if (groupsType != "Data not available" && !string.IsNullOrEmpty(groupsType))
                {
                    GroupsManage_Type = groupsType;
                }

                var dataUser = Intent.GetStringExtra("UserID") ?? "Data not available";
                if (dataUser != "Data not available" && !string.IsNullOrEmpty(groupsType))
                {
                    UserID = dataUser;
                }

                var ToolBar = FindViewById <Toolbar>(Resource.Id.toolbar);
                if (ToolBar != null)
                {
                    ToolBar.Title = GetText(Resource.String.Lbl_ExploreGroup);

                    Txt_Create = FindViewById <TextView>(Resource.Id.toolbar_title);

                    SetSupportActionBar(ToolBar);
                    SupportActionBar.SetDisplayShowCustomEnabled(true);
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    SupportActionBar.SetHomeButtonEnabled(true);
                    SupportActionBar.SetDisplayShowHomeEnabled(true);
                }

                GroupsSection       = (LinearLayout)FindViewById(Resource.Id.groupLiner);
                ManageGroupsSection = (LinearLayout)FindViewById(Resource.Id.ManagegroupLiner);

                GroupsRecylerView       = (RecyclerView)FindViewById(Resource.Id.Recyler);
                ManageGroupsRecylerView = (RecyclerView)FindViewById(Resource.Id.groupsRecyler);

                Groups_Empty = (LinearLayout)FindViewById(Resource.Id.Page_LinerEmpty);

                IconGroups_Empty = (TextView)FindViewById(Resource.Id.Group_icon);

                Txt_Count_ManageGroups            = (TextView)FindViewById(Resource.Id.tv_groupscount);
                IconMore_ManageGroups             = (TextView)FindViewById(Resource.Id.iv_more_groups);
                Txt_Count_ManageGroups.Visibility = ViewStates.Gone;
                IconMore_ManageGroups.Visibility  = ViewStates.Gone;

                swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
                swipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight,
                                                           Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight,
                                                           Android.Resource.Color.HoloRedLight);
                swipeRefreshLayout.Refreshing = true;
                swipeRefreshLayout.Enabled    = true;

                Btn_SearchRandom = FindViewById <Button>(Resource.Id.SearchRandom_Button);

                IMethods.Set_TextViewIcon("1", IconMore_ManageGroups, IonIcons_Fonts.ChevronRight);
                IMethods.Set_TextViewIcon("2", IconGroups_Empty, "\uf0c0");

                Groups_Empty.Visibility = ViewStates.Gone;

                //*************************************************************************

                GroupsRecylerView.SetLayoutManager(new GridLayoutManager(this, 3));
                GroupsAdapter = new GroupsAdapter(this);
                GroupsRecylerView.AddItemDecoration(new GridSpacingItemDecoration(2, 3, true));
                GroupsRecylerView.SetAdapter(GroupsAdapter);
                GroupsRecylerView.NestedScrollingEnabled = false;

                //*************************************************************************

                //Get Manage my or user groups and set any type adapter
                ManageGroupsRecylerView.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal,
                                                                                 false));
                ManageGroupsAdapter = new UserGroupsAdapter(this);
                ManageGroupsRecylerView.SetAdapter(ManageGroupsAdapter);
                ManageGroupsRecylerView.NestedScrollingEnabled = false;

                //When you have finished fetching the Manage Groups, the second connection is initiated by fetching Get_CommunitiesList_Group()
                Get_ManageGroups();

                //*************************************************************************

                //Show Ads
                AdsGoogle.Ad_RewardedVideo(this);
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }