Пример #1
0
        private void Initialize(ArticlesAdapterViewHolder holder, ArticleObject item)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, !string.IsNullOrEmpty(item.Image) ? item.Image : "blackdefault", holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                GlideImageLoader.LoadImage(ActivityContext, !string.IsNullOrEmpty(item.UserData?.Avatar) ? item.UserData.Avatar : "no_profile_image_circle", holder.UserImageProfile, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var color = Methods.FunString.RandomColor();
                holder.Category.SetBackgroundColor(Color.ParseColor(color));
                CategoryColor.Add(item.Id, color);

                string id = item.Url.Split('/').Last();

                string name = Methods.FunString.DecodeString(CategoriesController.ListCategories?.FirstOrDefault(a => a.Id == (item.Category))?.Name);
                if (string.IsNullOrEmpty(name))
                {
                    name = ActivityContext.GetString(Resource.String.Lbl_Unknown);
                }

                holder.Category.Text = name;

                holder.Description.Text = Methods.FunString.DecodeString(item.Description);
                holder.Title.Text       = Methods.FunString.DecodeString(item.Title);
                holder.Username.Text    = Methods.FunString.DecodeString(item.UserData?.Name);
                holder.ViewMore.Text    = ActivityContext.GetText(Resource.String.Lbl_ReadMore) + " >"; //READ MORE >
                holder.Time.Text        = Methods.FunString.DecodeString(item.TextTime);

                if (!holder.UserItem.HasOnClickListeners)
                {
                    holder.UserItem.Click += (sender, args) =>
                    {
                        try
                        {
                            AFragment.OpenChannel(item);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
 // Create new views (invoked by the layout manager)
 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
 {
     try
     {
         //Setup your layout here >> Style_Article_View
         var itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Style_Article_View, parent, false);
         var vh       = new ArticlesAdapterViewHolder(itemView, OnClick, OnLongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(null);
     }
 }