コード例 #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 SaerchPage_AdapterViewHolder(itemView, OnClick, OnLongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
         return(null);
     }
 }
コード例 #2
0
        public void Initialize(SaerchPage_AdapterViewHolder holder, Get_Search_Object.Page item)
        {
            try
            {
                var AvatarSplit     = item.Avatar.Split('/').Last();
                var getImage_Avatar = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskPage, 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.FolderDiskPage, 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.FolderDiskPage, CoverSplit);
                if (getImage_Cover == "File Dont Exists")
                {
                    IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskPage, item.Cover);
                }


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

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

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

                //Set style Btn Like page
                if (item.IsLiked == "no" || item.IsLiked == "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_Like);
                    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_Unlike);
                    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_Unlike);
                            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_Like);
                            holder.Button.Tag  = "false";
                        }

                        // Add Page Or Remove in DB
                        var dbDatabase = new SqLiteDatabase();
                        var data       = new DataTables.PageTB
                        {
                            PageId          = item.PageId,
                            UserId          = item.UserId,
                            PageName        = item.PageName,
                            PageTitle       = item.PageTitle,
                            PageDescription = item.PageDescription,
                            Avatar          = item.Avatar,
                            Cover           = item.Cover,
                            PageCategory    = item.PageCategory,
                            Website         = item.Website,
                            Facebook        = item.Facebook,
                            Google          = item.Google,
                            Vk                    = item.Vk,
                            Twitter               = item.Twitter,
                            Linkedin              = item.Linkedin,
                            Company               = item.Company,
                            Phone                 = item.Phone,
                            Address               = item.Address,
                            CallActionType        = item.CallActionType,
                            CallActionTypeUrl     = item.CallActionTypeUrl,
                            BackgroundImage       = item.BackgroundImage,
                            BackgroundImageStatus = item.BackgroundImageStatus,
                            Instgram              = item.Instgram,
                            Youtube               = item.Youtube,
                            Verified              = item.Verified,
                            Registered            = item.Registered,
                            Boosted               = item.Boosted,
                            About                 = item.About,
                            Id                    = item.Id,
                            Type                  = item.Type,
                            Url                   = item.Url,
                            Name                  = item.Name,
                            //Rating = item.Rating,
                            Category    = item.Category,
                            IsPageOnwer = Convert.ToString(item.IsPageOnwer),
                            Username    = item.Username
                        };
                        dbDatabase.Insert_Or_Delete_OnePagesTable(item.PageId, data);

                        var result = Client.Page.Like_Page(item.PageId).ConfigureAwait(false);

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