Пример #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_Article_View
         var itemView = LayoutInflater.From(parent.Context)
                        .Inflate(Resource.Layout.Style_Article_View, parent, false);
         var vh = new Articles_AdapterViewHolder(itemView, OnClick, OnLongClick);
         return(vh);
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
         return(null);
     }
 }
Пример #2
0
        public void Initialize(Articles_AdapterViewHolder holder, Get_Users_Articles_Object.Article item)
        {
            try
            {
                var ArticlesSplit     = item.thumbnail.Split('/').Last();
                var getImage_Articles = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskArticles, ArticlesSplit);
                if (getImage_Articles != "File Dont Exists")
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.Image, "ImagePlacholder.jpg", item.thumbnail, 0, false);
                        holder.Image.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskArticles, item.author.avatar);
                        ImageServiceLoader.Load_Image(holder.Image, "ImagePlacholder.jpg", item.thumbnail, 0, false);
                        holder.Image.Tag = "loaded";
                    }
                }

                var AvatarSplit     = item.author.avatar.Split('/').Last();
                var getImage_Avatar = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskImage, AvatarSplit);
                if (getImage_Avatar != "File Dont Exists")
                {
                    if (holder.UserImageProfile.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.UserImageProfile, "no_profile_image.png", getImage_Avatar, 1);
                        holder.UserImageProfile.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.UserImageProfile.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskImage, item.author.avatar);
                        ImageServiceLoader.Load_Image(holder.UserImageProfile, "no_profile_image.png", item.author.avatar, 1, false);
                        holder.UserImageProfile.Tag = "loaded";
                    }
                }

                holder.Category.SetBackgroundColor(Color.ParseColor(IMethods.Fun_String.RandomColor()));

                CategoriesController cat = new CategoriesController();
                string id = item.category_link.Split('/').Last();
                holder.Category.Text = cat.Get_Translate_Categories_Communities(id, item.category_name);

                holder.Description.Text = item.description;
                holder.Title.Text       = item.title;
                holder.Username.Text    = item.author.name;
                holder.ViewMore.Text    = Activity_Context.GetText(Resource.String.Lbl_ReadMore) + " >"; //READ MORE >
                holder.Time.Text        = item.posted;

                if (!holder.UserItem.HasOnClickListeners)
                {
                    holder.UserItem.Click += (sender, args) =>
                    {
                        try
                        {
                            var Int = new Intent(Activity_Context, typeof(User_Profile_Activity));
                            Int.PutExtra("UserId", item.author.user_id);
                            Int.PutExtra("UserType", "Articles");
                            Int.PutExtra("UserItem", JsonConvert.SerializeObject(item));
                            Activity_Context.StartActivity(Int);
                        }
                        catch (Exception e)
                        {
                            Crashes.TrackError(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }