public ReplyCommentAdapter(ReplyCommentActivity context) { try { HasStableIds = true; ActivityContext = context; PostEventListener = new CommentClickListener(ActivityContext, "Reply"); ReadMoreOption = new StReadMoreOption.Builder() .TextLength(250, StReadMoreOption.TypeCharacter) .MoreLabel(ActivityContext.GetText(Resource.String.Lbl_ReadMore)) .LessLabel(ActivityContext.GetText(Resource.String.Lbl_ReadLess)) .MoreLabelColor(Color.ParseColor(AppSettings.MainColor)) .LessLabelColor(Color.ParseColor(AppSettings.MainColor)) .LabelUnderLine(true) .Build(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder.ItemViewType == 666) { if (!(viewHolder is MainHolders.EmptyStateAdapterViewHolder emptyHolder)) { return; } emptyHolder.EmptyText.Text = "No Replies to be displayed"; return; } if (!(viewHolder is ReplyCommentAdapterViewHolder holder)) { return; } var item = ReplyCommentList[position]; if (item == null) { return; } if (AppSettings.FlowDirectionRightToLeft) { holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text)) { var changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); } else { holder.CommentText.Visibility = ViewStates.Gone; } if (holder.TimeTextView.Tag?.ToString() == "true") { return; } holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time)); holder.UserName.Text = item.Publisher.Name; GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); var textHighLighter = item.Publisher.Name; var textIsPro = string.Empty; if (item.Publisher.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (item.Publisher.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter) .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length); if (item.Publisher.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (item.Publisher.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (holder.ItemViewType == 1) { if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/"))) { File file2 = new File(item.CFile); var photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2); Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage); //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } else { GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); if (AppSettings.SetTabDarkTheme) { holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff")); } else { holder.LikeTextView.SetTextColor(Color.ParseColor("#000000")); } holder.LikeTextView.Tag = "Like"; } holder.TimeTextView.Tag = "true"; if (holder.Image.HasOnClickListeners) { return; } var postEventListener = new CommentClickListener(ActivityContext, "Reply"); //Create an Event holder.MainView.LongClick += (sender, e) => postEventListener.MoreCommentReplyPostClick(new CommentReplyClickEventArgs { CommentObject = item, Position = position, View = holder.MainView }); holder.Image.Click += (sender, args) => postEventListener.ProfilePostClick(new ProfileClickEventArgs { Holder = holder, CommentClass = item, Position = position, View = holder.MainView }); holder.ReplyTextView.Click += (sender, args) => { try { ActivityContext.TxtComment.Text = ""; ActivityContext.TxtComment.Text = "@" + item.Publisher.Username + " "; } catch (Exception e) { Console.WriteLine(e); } }; holder.LikeTextView.Click += delegate { try { if (holder.LikeTextView.Tag.ToString() == "Liked") { item.IsCommentLiked = false; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); if (AppSettings.SetTabDarkTheme) { holder.LikeTextView.SetTextColor(Color.ParseColor("#ffffff")); } else { holder.LikeTextView.SetTextColor(Color.ParseColor("#000000")); } holder.LikeTextView.Tag = "Like"; //sent api Dislike comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, false) }); } else { item.IsCommentLiked = true; holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; //sent api like comment PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.LikeUnLikeCommentAsync(item.Id, true) }); } } catch (Exception e) { Console.WriteLine(e); } }; holder.CommentImage.Click += (sender, args) => postEventListener.OpenImageLightBox(item); } catch (Exception exception) { Console.WriteLine(exception); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder.ItemViewType == 666) { if (!(viewHolder is AdapterHolders.EmptyStateAdapterViewHolder emptyHolder)) { return; } emptyHolder.EmptyText.Text = "No Replies to be displayed"; return; } if (!(viewHolder is CommentAdapterViewHolder holder)) { return; } var item = ReplyCommentList[position]; if (item == null) { return; } if (AppSettings.FlowDirectionRightToLeft) { holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } if (!string.IsNullOrEmpty(item.Orginaltext) || !string.IsNullOrWhiteSpace(item.Orginaltext)) { var text = Methods.FunString.DecodeString(item.Orginaltext); ReadMoreOption.AddReadMoreTo(holder.CommentText, new Java.Lang.String(text)); } else { holder.CommentText.Visibility = ViewStates.Gone; } if (holder.TimeTextView.Tag?.ToString() == "true") { return; } holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time), false); holder.UserName.Text = item.Publisher.Name; GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); var textHighLighter = item.Publisher.Name; var textIsPro = string.Empty; if (item.Publisher.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircle; } if (item.Publisher.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter) .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length); if (item.Publisher.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircle); } if (item.Publisher.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (holder.ItemViewType == 1) { if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/"))) { File file2 = new File(item.CFile); var photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2); Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage); //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } else { GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine) { item.Reaction ??= new WoWonderClient.Classes.Posts.Reaction(); holder.CountRating.Text = item.Reaction.Count + " " + ActivityContext.GetString(Resource.String.Lbl_Reactions); holder.RatingBar.Rating = (float)Convert.ToDouble(item.Reaction.Type); if (holder.RatingBar.Rating > 0) { holder.RatingText.Text = item.Reaction.Type; } else { holder.RatingText.Text = "0.0"; } //if (item.Reaction.Count > 0) //{ // holder.CountLikeSection.Visibility = ViewStates.Visible; // holder.CountLike.Text = Methods.FunString.FormatPriceValue(item.Reaction.Count); //} //else //{ // holder.CountLikeSection.Visibility = ViewStates.Gone; //} if (item.Reaction.IsReacted != null && item.Reaction.IsReacted.Value) { if (!string.IsNullOrEmpty(item.Reaction.Type)) { var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == item.Reaction.Type).Value?.Id ?? ""; switch (react) { case "1": ReactionComment.SetReactionPack(holder, ReactConstants.Like); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like); break; case "2": ReactionComment.SetReactionPack(holder, ReactConstants.Love); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_love); break; case "3": ReactionComment.SetReactionPack(holder, ReactConstants.HaHa); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_haha); break; case "4": ReactionComment.SetReactionPack(holder, ReactConstants.Wow); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_wow); break; case "5": ReactionComment.SetReactionPack(holder, ReactConstants.Sad); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_sad); break; case "6": ReactionComment.SetReactionPack(holder, ReactConstants.Angry); holder.LikeTextView.Tag = "Liked"; holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_angry); break; default: holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; if (item.Reaction.Count > 0) { holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like); } break; } } } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; if (item.Reaction.Count > 0) { holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like); } } } else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike) { if (item.Reaction.IsReacted != null && !item.Reaction.IsReacted.Value) { ReactionComment.SetReactionPack(holder, ReactConstants.Default); } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } switch (AppSettings.PostButton) { case PostButtonSystem.Wonder when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered); holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.Wonder: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } case PostButtonSystem.DisLike when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked); holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823")); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.DisLike: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } } } else { if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; } } holder.TimeTextView.Tag = "true"; } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder.ItemViewType == 666) { if (!(viewHolder is MainHolders.EmptyStateAdapterViewHolder emptyHolder)) { return; } emptyHolder.EmptyText.Text = "No Replies to be displayed"; return; } if (!(viewHolder is CommentAdapterViewHolder holder)) { return; } var item = ReplyCommentList[position]; if (item == null) { return; } if (AppSettings.FlowDirectionRightToLeft) { holder.BubbleLayout.LayoutDirection = LayoutDirection.Rtl; } if (!string.IsNullOrEmpty(item.Text) || !string.IsNullOrWhiteSpace(item.Text)) { var changer = new TextSanitizer(holder.CommentText, ActivityContext); changer.Load(Methods.FunString.DecodeString(item.Text)); } else { holder.CommentText.Visibility = ViewStates.Gone; } if (holder.TimeTextView.Tag?.ToString() == "true") { return; } holder.TimeTextView.Text = Methods.Time.TimeAgo(int.Parse(item.Time)); holder.UserName.Text = item.Publisher.Name; GlideImageLoader.LoadImage(ActivityContext, item.Publisher.Avatar, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Color); var textHighLighter = item.Publisher.Name; var textIsPro = string.Empty; if (item.Publisher.Verified == "1") { textHighLighter += " " + IonIconsFonts.CheckmarkCircled; } if (item.Publisher.IsPro == "1") { textIsPro = " " + IonIconsFonts.Flash; textHighLighter += textIsPro; } var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter) .SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length); if (item.Publisher.Verified == "1") { decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircled); } if (item.Publisher.IsPro == "1") { decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro); } decorator.Build(); if (holder.ItemViewType == 1) { if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/"))) { File file2 = new File(item.CFile); var photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2); Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage); //GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } else { GlideImageLoader.LoadImage(ActivityContext, Client.WebsiteUrl + "/" + item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine) { item.Reaction ??= new WoWonderClient.Classes.Posts.Reaction(); if ((bool)(item.Reaction != null & item.Reaction?.IsReacted)) { if (!string.IsNullOrEmpty(item.Reaction.Type)) { switch (item.Reaction.Type) { case "1": case "Like": ReactionComment.SetReactionPack(holder, ReactConstants.Like); holder.LikeTextView.Tag = "Liked"; break; case "2": case "Love": ReactionComment.SetReactionPack(holder, ReactConstants.Love); holder.LikeTextView.Tag = "Liked"; break; case "3": case "HaHa": ReactionComment.SetReactionPack(holder, ReactConstants.HaHa); holder.LikeTextView.Tag = "Liked"; break; case "4": case "Wow": ReactionComment.SetReactionPack(holder, ReactConstants.Wow); holder.LikeTextView.Tag = "Liked"; break; case "5": case "Sad": ReactionComment.SetReactionPack(holder, ReactConstants.Sad); holder.LikeTextView.Tag = "Liked"; break; case "6": case "Angry": ReactionComment.SetReactionPack(holder, ReactConstants.Angry); holder.LikeTextView.Tag = "Liked"; break; default: holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; break; } } } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; } } else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike) { if ((bool)(item.Reaction != null & !item.Reaction?.IsReacted)) { ReactionComment.SetReactionPack(holder, ReactConstants.Default); } if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } switch (AppSettings.PostButton) { case PostButtonSystem.Wonder when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered); holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.Wonder: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } case PostButtonSystem.DisLike when item.IsCommentWondered: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked); holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823")); holder.DislikeTextView.Tag = "Disliked"; break; } case PostButtonSystem.DisLike: { holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike); holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.DislikeTextView.Tag = "Dislike"; break; } } } else { if (item.IsCommentLiked) { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked); holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor)); holder.LikeTextView.Tag = "Liked"; } else { holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like); holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); holder.LikeTextView.Tag = "Like"; } } holder.TimeTextView.Tag = "true"; } catch (Exception exception) { Console.WriteLine(exception); } }