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); } }
private void AddOrRemoveEvent(bool addEvent) { try { // true += // false -= if (addEvent) { CommentsAdapter.AvatarClick += CommentsAdapter_AvatarClick; if (!string.IsNullOrEmpty(Json)) { var item = JsonConvert.DeserializeObject <PostsObject>(Json); ClickListeners = new SocialIoClickListeners(Activity); if (!CommentCount.HasOnClickListeners) { CommentCount.Click += (sender, e) => ClickListeners.OnCommentPostClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = Mainview }, "YoutubePost"); } if (!LikeCount.HasOnClickListeners) { LikeCount.Click += (sender, e) => ClickListeners.OnLikedPostClick(new LikeNewsFeedClickEventArgs { View = Mainview, NewsFeedClass = item, LikeButton = LikeCount }); } if (!LikeIcon.HasOnClickListeners) { LikeIcon.Click += (sender, e) => ClickListeners.OnLikeNewsFeedClick(new LikeNewsFeedClickEventArgs { View = Mainview, 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 = Mainview }, "YoutubePost"); } if (!CommentIcon.HasOnClickListeners) { CommentIcon.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = Mainview }, "YoutubePost"); } if (!ViewCommentsButton.HasOnClickListeners) { ViewCommentsButton.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = Mainview }, "YoutubePost"); } if (!MoreIcon.HasOnClickListeners) { MoreIcon.Click += (sender, e) => ClickListeners.OnMoreClick(new MoreFeedClickEventArgs { NewsFeedClass = item, View = Mainview, IsOwner = item.IsOwner }, false, "YoutubePost"); } if (!ShareIcon.HasOnClickListeners) { ShareIcon.Click += (sender, e) => ClickListeners.OnShareClick(new ShareFeedClickEventArgs { NewsFeedClass = item, View = Mainview }); } } } } catch (Exception e) { Console.WriteLine(e); } }
private void AddOrRemoveEvent(bool addEvent) { try { // true += // false -= if (addEvent) { if (!string.IsNullOrEmpty(Json)) { var item = JsonConvert.DeserializeObject <PostsObject>(Json); GlideImageLoader.LoadImage(Activity, !string.IsNullOrEmpty(item.MediaSet[0].Extra) ? item.MediaSet[0].Extra : item.MediaSet[0].File, ImageDisplay, ImageStyle.FitCenter, ImagePlaceholders.Color); GlideImageLoader.LoadImage(Activity, !string.IsNullOrEmpty(item.MediaSet[0].File) ? item.MediaSet[0].File : item.MediaSet[0].Extra, ImageDisplay, ImageStyle.FitCenter, ImagePlaceholders.Color); ClickListeners = new SocialIoClickListeners(Activity); if (!CommentCount.HasOnClickListeners) { CommentCount.Click += (sender, e) => ClickListeners.OnCommentPostClick(new CommentFeedClickEventArgs { View = Mainview, NewsFeedClass = item }, "ImagePost"); } if (!LikeCount.HasOnClickListeners) { LikeCount.Click += (sender, e) => ClickListeners.OnLikedPostClick(new LikeNewsFeedClickEventArgs { View = Mainview, NewsFeedClass = item, LikeButton = LikeIcon }); } if (!LikeIcon.HasOnClickListeners) { LikeIcon.Click += (sender, e) => ClickListeners.OnLikeNewsFeedClick(new LikeNewsFeedClickEventArgs { View = Mainview, 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 = Mainview }, "ImagePost"); } if (!CommentIcon.HasOnClickListeners) { CommentIcon.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = Mainview }, "ImagePost"); } if (!ViewCommentsButton.HasOnClickListeners) { ViewCommentsButton.Click += (sender, e) => ClickListeners.OnCommentClick(new CommentFeedClickEventArgs { NewsFeedClass = item, View = Mainview }, "ImagePost"); } if (!MoreIcon.HasOnClickListeners) { MoreIcon.Click += (sender, e) => ClickListeners.OnMoreClick(new MoreFeedClickEventArgs { NewsFeedClass = item, View = Mainview, IsOwner = item.IsOwner }, false, "ImagePost"); } if (!ShareIcon.HasOnClickListeners) { ShareIcon.Click += (sender, e) => ClickListeners.OnShareClick(new ShareFeedClickEventArgs { NewsFeedClass = item, View = Mainview }); } } } } catch (Exception e) { Console.WriteLine(e); } }