Beispiel #1
0
        public void DisplayData(string fullname, string description, string avatar, string time, string videofile, int likesCount, bool isliked, bool isSaved, int votesCount)
        {
            try
            {
                Fullname.Text     = fullname;
                TimeTextView.Text = time;
                GlideImageLoader.LoadImage(Activity, avatar, UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var textSanitizer = new TextSanitizer(Description, Activity);

                if (!string.IsNullOrEmpty(description))
                {
                    ReadMoreOption.AddReadMoreTo(Description, Methods.FunString.DecodeString(description));
                    textSanitizer.Load(Methods.FunString.DecodeString(description));
                }
                else
                {
                    Description.Visibility = ViewStates.Gone;
                }

                CommentIcon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444"));
                LikeCount.Text = likesCount + " " + Context.GetText(Resource.String.Lbl_Likes);
                LikeIcon.Tag   = "Like";

                if (isliked)
                {
                    LikeIcon.SetTextColor(Color.ParseColor("#ed4856"));
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, LikeIcon, IonIconsFonts.IosHeart);
                    LikeIcon.Tag = "Liked";
                }

                if (!isSaved)
                {
                    Favicon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444"));
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.IosStarOutline);
                    Favicon.Tag = "Add";
                }
                else
                {
                    Favicon.SetTextColor(Color.ParseColor("#FFCE00"));
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.AndroidStar);
                    Favicon.Tag = "Added";
                }

                CommentCount.Text = votesCount + " " + Context.GetText(Resource.String.Lbl_Comments);

                if (votesCount <= 4)
                {
                    ViewCommentsButton.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #2
0
        public void SetDataDynamicForViewHolder(View itemView, TextView username, ImageView userAvatar, AutoLinkTextView description, TextView likeIcon, TextView favIcon, TextView commentCount, TextView likeCount, TextView viewMoreComments, TextView timeText, TextView commentIcon, TextView moreIcon, TextView shareIcon, TextView isBoostedIcon, PostsObject item)
        {
            try
            {
                if (item == null)
                {
                    return;
                }

                TextSanitizerAutoLink = new TextSanitizer(description, ActivityContext);

                GlideImageLoader.LoadImage(ActivityContext, item.Avatar, userAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                username.Text = item.Username;

                string time = Methods.Time.TimeAgo(Convert.ToInt32(item.Time));
                timeText.Text = time;

                if (!string.IsNullOrEmpty(description.Text))
                {
                    ReadMoreOption.AddReadMoreTo(description, item.Description);
                    TextSanitizerAutoLink.Load(item.Description);
                }
                else
                {
                    description.Visibility = ViewStates.Gone;
                }

                if (item.Boosted == "1")
                {
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, isBoostedIcon, IonIconsFonts.RibbonA);
                    isBoostedIcon.Text      += " " + ActivityContext.GetString(Resource.String.Lbl_Promoted);
                    isBoostedIcon.Visibility = ViewStates.Visible;
                }

                likeIcon.Tag = item.IsLiked ? "Like" : "Liked";
                ClickListeners.SetLike(likeIcon);

                favIcon.Tag = item.IsSaved ? "Add" : "Added";
                ClickListeners.SetFav(favIcon);

                commentCount.Text = item.Votes + " " + ActivityContext.GetString(Resource.String.Lbl_Comments);
                likeCount.Text    = item.Likes + " " + ActivityContext.GetString(Resource.String.Lbl_Likes);

                if (item.Votes > 0)
                {
                    viewMoreComments.Visibility = ViewStates.Visible;
                    viewMoreComments.Text       = ActivityContext.GetString(Resource.String.Lbl_ShowAllComments);
                }
                else
                {
                    viewMoreComments.Visibility = ViewStates.Gone;
                }

                if (!commentCount.HasOnClickListeners)
                {
                    commentCount.Click += (sender, e) => ClickListeners.OnCommentPostClick(new CommentFeedClickEventArgs {
                        View = itemView, NewsFeedClass = item
                    }, "NewsFeedPost");
                }

                if (!likeCount.HasOnClickListeners)
                {
                    likeCount.Click += (sender, e) => ClickListeners.OnLikedPostClick(new LikeNewsFeedClickEventArgs {
                        View = itemView, NewsFeedClass = item, LikeButton = likeCount
                    });
                }

                if (!likeIcon.HasOnClickListeners)
                {
                    likeIcon.Click += (sender, e) => ClickListeners.OnLikeNewsFeedClick(new LikeNewsFeedClickEventArgs {
                        View = itemView, NewsFeedClass = item, LikeButton = likeIcon
                    });
                }

                if (!favIcon.HasOnClickListeners)
                {
                    favIcon.Click += (sender, e) => ClickListeners.OnFavNewsFeedClick(new FavNewsFeedClickEventArgs {
                        NewsFeedClass = item, FavButton = favIcon
                    });
                }

                if (!userAvatar.HasOnClickListeners)
                {
                    userAvatar.Click += (sender, e) => ClickListeners.OnAvatarImageFeedClick(new AvatarFeedClickEventArgs {
                        NewsFeedClass = item, Image = userAvatar, View = itemView
                    }, "NewsFeedPost");
                }

                if (!commentIcon.HasOnClickListeners)
                {
                    commentIcon.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs {
                        NewsFeedClass = item, View = itemView
                    }, "NewsFeedPost");
                }

                if (!viewMoreComments.HasOnClickListeners)
                {
                    viewMoreComments.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs {
                        NewsFeedClass = item, View = itemView
                    }, "NewsFeedPost");
                }

                if (!moreIcon.HasOnClickListeners)
                {
                    moreIcon.Click += (sender, e) => ClickListeners.OnMoreClick(new MoreFeedClickEventArgs {
                        NewsFeedClass = item, View = itemView, IsOwner = item.IsOwner
                    }, true, "NewsFeedPost");
                }

                if (!shareIcon.HasOnClickListeners)
                {
                    shareIcon.Click += (sender, e) => ClickListeners.OnShareClick(new ShareFeedClickEventArgs {
                        NewsFeedClass = item, View = itemView
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }