Ejemplo n.º 1
0
 // Create new views (invoked by the layout manager)
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Style_HPage_view
         var itemView = LayoutInflater.From(parent.Context)
                        .Inflate(Resource.Layout.Style_HPage_view, parent, false);
         var vh = new SearchGroup_AdapterViewHolder(itemView, OnClick, OnLongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
         return(null);
     }
 }
Ejemplo n.º 2
0
        public void Initialize(SearchGroup_AdapterViewHolder holder, Get_Search_Object.Group item)
        {
            try
            {
                var AvatarSplit     = item.Avatar.Split('/').Last();
                var getImage_Avatar =
                    IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskGroup, AvatarSplit);
                if (getImage_Avatar != "File Dont Exists")
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", getImage_Avatar, 1);
                        holder.Image.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskGroup, item.Avatar);
                        ImageServiceLoader.Load_Image(holder.Image, "no_profile_image.png", item.Avatar, 1);
                        holder.Image.Tag = "loaded";
                    }
                }

                var CoverSplit     = item.Cover.Split('/').Last();
                var getImage_Cover = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskGroup, CoverSplit);
                if (getImage_Cover == "File Dont Exists")
                {
                    IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskGroup, item.Cover);
                }


                IMethods.Set_TextViewIcon("1", holder.IconGroup, IonIcons_Fonts.PersonStalker);
                string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(item.GroupName));
                holder.Name.Text = IMethods.Fun_String.SubStringCutOf(name, 14);

                CategoriesController cat = new CategoriesController();
                holder.About.Text = cat.Get_Translate_Categories_Communities(item.CategoryId, item.Category);

                var drawable = TextDrawable.TextDrawable.TextDrawbleBuilder.BeginConfig().FontSize(30).EndConfig()
                               .BuildRound("", Color.ParseColor("#1A237E"));
                holder.ImageView.SetImageDrawable(drawable);

                //Set style Btn Like page
                if (item.IsJoined == "no" || item.IsJoined == "No")
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                    holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor));
                    holder.Button.Text = Activity_Context.GetText(Resource.String.Btn_Join_Group);
                    holder.Button.Tag  = "false";
                }
                else
                {
                    holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                    holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                    holder.Button.Text = Activity_Context.GetText(Resource.String.Btn_Joined);
                    holder.Button.Tag  = "true";
                }

                if (!holder.Button.HasOnClickListeners)
                {
                    holder.Button.Click += (sender, args) =>
                    {
                        if (holder.Button.Tag.ToString() == "false")
                        {
                            holder.Button.SetBackgroundResource(Resource.Drawable
                                                                .follow_button_profile_friends_pressed);
                            holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                            holder.Button.Text = Activity_Context.GetText(Resource.String.Btn_Joined);
                            holder.Button.Tag  = "true";
                        }
                        else
                        {
                            holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                            holder.Button.SetTextColor(Color.ParseColor(Settings.MainColor));
                            holder.Button.Text = Activity_Context.GetText(Resource.String.Btn_Join_Group);
                            holder.Button.Tag  = "false";
                        }

                        // Add Group Or Remove in DB
                        var dbDatabase = new SqLiteDatabase();
                        var data       = new DataTables.GroupsTB
                        {
                            Id          = item.Id,
                            UserId      = item.UserId,
                            GroupName   = item.GroupName,
                            GroupTitle  = item.GroupTitle,
                            Avatar      = item.Avatar,
                            Cover       = item.Cover,
                            About       = item.About,
                            Category    = item.Category,
                            Privacy     = item.Privacy,
                            JoinPrivacy = item.JoinPrivacy,
                            Active      = item.Active,
                            Registered  = item.Registered,
                            GroupId     = item.GroupId,
                            Url         = item.Url,
                            Name        = item.Name,
                            CategoryId  = item.CategoryId,
                            Type        = item.Type,
                            Username    = item.Username
                        };

                        dbDatabase.Insert_Or_Delete_OneGroupsTable(item.GroupId, data);

                        var result = Client.Group.Join_Group(item.GroupId).ConfigureAwait(false);

                        dbDatabase.Dispose();
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }