//Edit Or Delete Comment private void MAdapterOnItemLongClick(object sender, CommentAdapterClickEventArgs e) { try { var position = e.Position; if (position > -1) { ItemComments = MAdapter.GetItem(position); if (ItemComments != null) { TypeDialog = "MoreComment"; var arrayAdapter = new List <string>(); var dialogList = new MaterialDialog.Builder(Activity).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); if (ItemComments.IsCommentOwner && UserDetails.IsLogin) { arrayAdapter.Add(Activity.GetText(Resource.String.Lbl_Delete)); arrayAdapter.Add(Activity.GetText(Resource.String.Lbl_Edit)); } arrayAdapter.Add(Activity.GetText(Resource.String.Lbl_Copy)); dialogList.Items(arrayAdapter); dialogList.PositiveText(Activity.GetText(Resource.String.Lbl_Close)).OnPositive(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); } } } catch (Exception exception) { Console.WriteLine(exception); } }
//Event Menu >> Edit Comment private void EditCommentEvent(CommentObject item) { try { if (Methods.CheckConnectivity()) { TypeDialog = "EditComment"; CommentObject = item; var dialog = new MaterialDialog.Builder(MainContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); dialog.Title(Resource.String.Lbl_Edit); dialog.Input(Context.GetString(Resource.String.Lbl_Write_comment), Methods.FunString.DecodeString(item.Text), this); dialog.InputType(InputTypes.TextFlagImeMultiLine); dialog.PositiveText(MainContext.GetText(Resource.String.Lbl_Update)).OnPositive(this); dialog.NegativeText(MainContext.GetText(Resource.String.Lbl_Cancel)).OnNegative(this); dialog.Build().Show(); dialog.AlwaysCallSingleChoiceCallback(); } else { Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
public void OnCommentAdded(CommentObject co) { CommentingMaster.CommentData data = CommentingMaster.ToCommentData (co); print ("Added"); print (data.comment); }
public void CreateTest() { o = CommentObjectFactory.Create(id, commentAddTime, commentText, subject, email); validateResults(id, commentAddTime, commentText, subject, email); }
/// <summary> /// Gets the comment. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public ActionResult getComment(int id) { Array data = null; var comment = new CommentObject(); var url = string.Empty; try { if (id != 0) { comment = _exam.GetComment(string.Format("questions/{0}/comments?order=desc&sort=creation&site=stackoverflow&filter=!9YdnSQVog", id)); data = comment.items.ToArray(); } responseStatus = "OK"; } catch (Exception ex) { if (String.IsNullOrEmpty(ex.Message)) { responseStatus = "ERROR"; } responseText = ex.Message; } return(Json(new { status = responseStatus, message = responseText, data })); }
public virtual void OnAddComment(CommentObject comment, ABCStandardEventArg e) { if (this.AddCommentEvent != null) { this.AddCommentEvent(comment, e); } }
public async Task <long> CreateComment(CommentObject comObj, long postId) { var post = await _database.Posts.FirstOrDefaultAsync(i => i.Id == postId); if (post == null) { return(-1); } var comment = new Comment() { Author = comObj.Author, Text = comObj.Text, CreateDate = DateTime.Now, PostId = postId, Post = post }; post.CommentCount++; await _database.AddAsync(comment); await _database.SaveChangesAsync(); return(comment.Id); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { try { View view = inflater.Inflate(Resource.Layout.ReplyCommentLayout, container, false); UserinfoComment = JsonConvert.DeserializeObject <CommentObject>(Arguments.GetString("CommentObject")); CommentId = Arguments.GetString("CommentId"); InitComponent(view); InitToolbar(view); SetRecyclerViewAdapters(); SendButton.Click += SendButtonOnClick; MAdapter.AvatarClick += MAdapterOnAvatarClick; LikeIcon.Click += LikeIconOnClick; GetReply(); return(view); } catch (Exception exception) { Console.WriteLine(exception); return(null); } }
//Event Menu >> Delete Comment private void DeleteCommentEvent(CommentObject item) { try { if (Methods.CheckConnectivity()) { TypeDialog = "DeleteComment"; CommentObject = item; var dialog = new MaterialDialog.Builder(MainContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); dialog.Title(MainContext.GetText(Resource.String.Lbl_DeleteComment)); dialog.Content(MainContext.GetText(Resource.String.Lbl_AreYouSureDeleteComment)); dialog.PositiveText(MainContext.GetText(Resource.String.Lbl_Yes)).OnPositive(this); dialog.NegativeText(MainContext.GetText(Resource.String.Lbl_No)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.ItemsCallback(this).Build().Show(); } else { Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
public CommentProfileObject(CommentProfileDbRecord dbRecord) : base(dbRecord) { DbRecord.Comments = DbRecord.Comments ?? new CommentDbRecord(); DbRecord.Profiles = DbRecord.Profiles ?? new ProfileDbRecord(); CommentObject = new CommentObject(DbRecord.Comments); ProfileObject = new ProfileObject(DbRecord.Profiles); }
public CommentEventObject(CommentEventDbRecord eventDbRecord) : base(eventDbRecord) { DbRecord.Events = DbRecord.Events ?? new EventDbRecord(); DbRecord.Comments = DbRecord.Comments ?? new CommentDbRecord(); EventObject = new EventObject(DbRecord.Events); CommentObject = new CommentObject(DbRecord.Comments); }
public async Task <IActionResult> Post([FromBody] CommentObject comObj, [FromQuery] long postId) { var id = await _commentService.CreateComment(comObj, postId); if (id == -1) { return(NotFound()); } return(CreatedAtRoute("GetComment", new { id }, comObj)); }
public async Task <IActionResult> Put(long id, [FromBody] CommentObject comObj) { var updatedId = await _commentService.UpdateComment(comObj, id); if (updatedId == -1) { return(NotFound()); } return(Ok(updatedId)); }
public CommentModel ToCommentModelFrom(CommentObject commentObject) { var comment = new CommentModel(); comment.DateCreated = commentObject.When; comment.Content = commentObject.Content; comment.Author = ToUserModelFrom(commentObject.Author); comment.Post = ToPostModelFrom(commentObject.Post); //comment.Id = commentObject.Id; return(comment); }
public override void SetupDialog(Dialog dialog, int style) { try { base.SetupDialog(dialog, style); View contentView = View.Inflate(Context, Resource.Layout.Style_Bottom_Sheet_Reply, null); dialog.SetContentView(contentView); var layoutParams = (CoordinatorLayout.LayoutParams)((View)contentView.Parent).LayoutParameters; var behavior = layoutParams.Behavior; if (behavior != null && behavior.GetType() == typeof(BottomSheetBehavior)) { ((BottomSheetBehavior)behavior).SetBottomSheetCallback(MBottomSheetBehaviorCallback); } Instance = this; Type = Arguments.GetString("Type"); if (Arguments.ContainsKey("Object")) { Comment = JsonConvert.DeserializeObject <CommentObject>(Arguments.GetString("Object")); } if (Type == "video") { if (TabbedMainActivity.GetInstance().MyResponsesFragment.activePage == 1) { ActivityContext = TabbedMainActivity.GetInstance().MyResponsesFragment.ForYouResponses; } else { ActivityContext = TabbedMainActivity.GetInstance().MyResponsesFragment.FollowingResponses; } //ActivityContext = HomeResponsePlayerFragment.GetInstance(); } InitComponent(contentView); SetRecyclerViewAdapters(); CommentClickListener = new ResponseCommentClickListener((Activity)ActivityContext.Context, "Reply"); SendButton.Click += SendButton_Click; LikeButton.Click += OnLikeButtonClick; UnLikeButton.Click += OnUnLikeButtonClick; UnLikeButton.Visibility = ViewStates.Gone; LoadReplies(); } catch (Exception e) { Console.WriteLine(e); } }
private void LoadUserData(CommentObject cl) { try { GlideImageLoader.LoadImage(Activity, cl.Avatar, ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Color); TxtUserName.Text = "@" + cl.Username; TxtFullName.Text = Methods.FunString.DecodeString(cl.Name); } catch (Exception e) { Console.WriteLine(e); } }
private void LoadUserData(CommentObject cl) { try { GlideImageLoader.LoadImage(Activity, cl.Avatar, UserProfileImage, ImageStyle.RoundedCrop, ImagePlaceholders.Color); UserProfileImage.SetScaleType(ImageView.ScaleType.CenterCrop); Username.Text = "@" + cl.Username; Fullname.Text = Methods.FunString.DecodeString(cl.Name); } catch (Exception e) { Console.WriteLine(e); } }
public static CommentProfileObject Create(CommentObject commentObject, ProfileObject profileObject, string commentID, string userID) { var o = new CommentProfileDbRecord { CommentID = commentID, ProfileID = userID, Comments = commentObject?.DbRecord ?? new CommentDbRecord(), Profiles = profileObject?.DbRecord ?? new ProfileDbRecord() }; o.CommentID = o.Comments.ID; o.ProfileID = o.Profiles.ID; return(new CommentProfileObject(o)); }
public static CommentEventObject Create(EventObject eventObject, CommentObject commentObject, string eventID, string commentID) { var o = new CommentEventDbRecord { EventID = eventID, CommentID = commentID, Events = eventObject?.DbRecord ?? new EventDbRecord(), Comments = commentObject?.DbRecord ?? new CommentDbRecord() }; o.EventID = o.Events.ID; o.CommentID = o.Comments.ID; return(new CommentEventObject(o)); }
public async Task <long> UpdateComment(CommentObject comObj, long id) { var comment = await _database.Comments.FirstOrDefaultAsync(i => i.Id == id); if (comment == null) { return(-1); } comment.Author = comObj.Author; comment.CreateDate = DateTime.Now; comment.Text = comObj.Text; await _database.SaveChangesAsync(); return(comment.Id); }
public ActionResult AddComment(string topicId, string content) { var topic = topicService.Load(topicId); if (topic.ListComment == null) { topic.ListComment = new List<CommentObject>(); } CommentObject comment = new CommentObject(); comment.Content = content; comment.ParentConten = "parentContent"; comment.Id = Guid.NewGuid().ToString(); comment.CreateBy = (UserObject)Session["user"]; comment.CreateDate = DateTime.Now; comment.isDeleted = false; topic.ListComment.Add(comment); topicService.Save(topic); return Json(comment, JsonRequestBehavior.AllowGet); }
public void CreateTest() { var r = GetRandom.Object <CommentEventDbRecord>(); var newEvent = new EventObject(r.Events); var newComment = new CommentObject(r.Comments); string e = Constants.Unspecified; string c = Constants.Unspecified; var o = CommentEventObjectFactory.Create(newEvent, newComment, e, c); Assert.AreEqual(o.EventObject.DbRecord, r.Events); Assert.AreEqual(o.CommentObject.DbRecord, r.Comments); Assert.AreEqual(o.DbRecord.CommentID, r.Comments.ID); Assert.AreEqual(o.DbRecord.EventID, r.Events.ID); Assert.AreEqual(o.DbRecord.Events, r.Events); Assert.AreEqual(o.DbRecord.Comments, r.Comments); }
public void CreateTest() { var r = GetRandom.Object <CommentProfileDbRecord>(); var newComment = new CommentObject(r.Comments); var newProfile = new ProfileObject(r.Profiles); string c = Constants.Unspecified; string p = Constants.Unspecified; var o = CommentProfileObjectFactory.Create(newComment, newProfile, c, p); Assert.AreEqual(o.CommentObject.DbRecord, r.Comments); Assert.AreEqual(o.ProfileObject.DbRecord, r.Profiles); Assert.AreEqual(o.DbRecord.CommentID, r.Comments.ID); Assert.AreEqual(o.DbRecord.ProfileID, r.Profiles.ID); Assert.AreEqual(o.DbRecord.Profiles, r.Profiles); Assert.AreEqual(o.DbRecord.Comments, r.Comments); }
public void LoadProfile(string json, string type) { try { if (!string.IsNullOrEmpty(json)) { switch (type) { case "comment": UserinfoComment = JsonConvert.DeserializeObject <CommentObject>(json); LoadUserData(UserinfoComment); break; case "UserData": UserinfoData = JsonConvert.DeserializeObject <UserDataObject>(json); LoadUserData(UserinfoData); Url = UserinfoData.Url; break; case "OneSignalNotification": UserinfoOneSignal = JsonConvert.DeserializeObject <UserDataObject>(json); LoadUserData(UserinfoOneSignal); break; default: GlideImageLoader.LoadImage(Activity, Arguments.GetString("avatar"), ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Color); TxtFullName.Text = Arguments.GetString("fullname"); break; } } else { GlideImageLoader.LoadImage(Activity, Arguments.GetString("avatar"), ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Color); TxtFullName.Text = Arguments.GetString("fullname"); } //Add Api LoadExploreFeed(); } catch (Exception e) { Console.WriteLine(e); } }
public async static Task <CommentsObject> GetCommentsOfAnswer(int ansId) { dynamic dynComObj = await GetResultFromURL(ANSWER_PATH + ansId + "/comments.json"); CommentsObject commentsObj = new CommentsObject(); commentsObj.Count = dynComObj.count; ObservableCollection <CommentObject> comments = new ObservableCollection <CommentObject>(); foreach (var comment in dynComObj.comments) { comments.Add(CommentObject.fromDynamic(comment)); } commentsObj.Comments = comments; return(commentsObj); }
public void Initialize([NotNull] CommentObject comment) { characterPicture.sprite = comment.character.profilePicture; characterName.text = comment.character.GetNameString(); text.text = Localization.Localization.Get(comment.text); if (comment.responseComments.Count == 0) { Destroy(responseCommentParent.gameObject); } else { foreach (var subComment in comment.responseComments) { var instance = GameObject.Instantiate(responseCommentPrefab, responseCommentParent); var sub = instance.GetComponent <CommentResponse>(); sub.Initialize(subComment); } } }
public static void OpenProfile(Activity activity, string userId, CommentObject item) { try { if (userId != UserDetails.UserId) { Bundle bundle = new Bundle(); bundle.PutString("userinfo", JsonConvert.SerializeObject(item)); bundle.PutString("type", "comment"); bundle.PutString("userid", userId); bundle.PutString("avatar", item.Avatar); bundle.PutString("fullname", item.Username); if (AppSettings.ProfileTheme == ProfileTheme.DefaultTheme) { UserProfileFragment profileFragment = new UserProfileFragment { Arguments = bundle }; HomeActivity.GetInstance()?.OpenFragment(profileFragment); } else if (AppSettings.ProfileTheme == ProfileTheme.TikTheme) { TikUserProfileFragment profileFragment = new TikUserProfileFragment { Arguments = bundle }; HomeActivity.GetInstance()?.OpenFragment(profileFragment); } } else { HomeActivity.GetInstance()?.NavigationTabBar.SetModelIndex(4, true); } } catch (Exception e) { Console.WriteLine(e); } }
public override void SetupDialog(Dialog dialog, int style) { try { base.SetupDialog(dialog, style); View contentView = View.Inflate(Context, Resource.Layout.Style_Bottom_Sheet_Reply, null); dialog.SetContentView(contentView); var layoutParams = (CoordinatorLayout.LayoutParams)((View)contentView.Parent).LayoutParameters; var behavior = layoutParams.Behavior; if (behavior != null && behavior.GetType() == typeof(BottomSheetBehavior)) { ((BottomSheetBehavior)behavior).SetBottomSheetCallback(MBottomSheetBehaviorCallback); } if (Arguments.ContainsKey("Object")) { Comment = JsonConvert.DeserializeObject <CommentObject>(Arguments.GetString("Object")); } ActivitiesView = GlobalContext.UserChannelFragment != null ? GlobalContext.UserChannelFragment.ActivitiesFragment.ActivitiesViewFragment : GlobalContext.MyChannelFragment.ActivitiesFragment.ActivitiesViewFragment; InitComponent(contentView); SetRecyclerViewAdapters(); SendButton.Click += SendButton_Click; LikeButton.Click += OnLikeButtonClick; UnLikeButton.Click += OnUnLikeButtonClick; LoadReplies(); } catch (Exception e) { Console.WriteLine(e); } }
public void MoreCommentPostClick(CommentObject item) { try { if (Methods.CheckConnectivity()) { TypeDialog = "MoreComment"; CommentObject = item; var arrayAdapter = new List <string>(); var dialogList = new MaterialDialog.Builder(MainContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); arrayAdapter.Add(Context.GetString(Resource.String.Lbl_CopeText)); if (CommentObject?.IsCommentOwner != null && (bool)CommentObject?.IsCommentOwner || CommentObject?.CommentUserData?.Id == UserDetails.UserId) { arrayAdapter.Add(Context.GetString(Resource.String.Lbl_Edit)); arrayAdapter.Add(Context.GetString(Resource.String.Lbl_Delete)); } dialogList.Title(Context.GetString(Resource.String.Lbl_More)); dialogList.Items(arrayAdapter); dialogList.PositiveText(MainContext.GetText(Resource.String.Lbl_Close)).OnNegative(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); } else { Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
//Add Comment private async void ImgSentOnClick(object sender, EventArgs e) { try { if (UserDetails.IsLogin) { if (!string.IsNullOrEmpty(TxtComment.Text)) { if (Methods.CheckConnectivity()) { if (MAdapter.CommentList.Count == 0) { EmptyStateLayout.Visibility = ViewStates.Gone; MRecycler.Visibility = ViewStates.Visible; } //Comment Code string time = Methods.Time.TimeAgo(DateTime.Now, false); int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string time2 = unixTimestamp.ToString(); string message = TxtComment.Text; var postId = MAdapter.CommentList.FirstOrDefault(a => a.ActivityId == Convert.ToInt32(ActivityId))?.PostId ?? 0; var comment = new CommentObject { Text = message, TextTime = time, UserId = Convert.ToInt32(UserDetails.UserId), Id = Convert.ToInt32(time2), IsCommentOwner = true, ActivityId = Convert.ToInt32(ActivityId), CommentUserData = new UserDataObject { Avatar = UserDetails.Avatar, Username = UserDetails.Username, Name = UserDetails.FullName, Cover = UserDetails.Cover }, CommentReplies = new List <ReplyObject>(), DisLikes = 0, IsDislikedComment = 0, IsLikedComment = 0, Likes = 0, Pinned = "", PostId = postId, RepliesCount = 0, Time = unixTimestamp }; MAdapter.CommentList.Add(comment); int index = MAdapter.CommentList.IndexOf(comment); MAdapter.NotifyItemInserted(index); MRecycler.ScrollToPosition(MAdapter.CommentList.IndexOf(MAdapter.CommentList.Last())); //Api request var(respondCode, respond) = await RequestsAsync.Activities.AddCommentActivity_Http(ActivityId, message); if (respondCode.Equals(200)) { if (respond is MessageIdObject messageId) { var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2)); if (dataComment != null) { dataComment.Id = messageId.Id; } } } else { Methods.DisplayReportResult(Activity, respond); } //Hide keyboard TxtComment.Text = ""; TxtComment.ClearFocus(); } else { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } } else { PopupDialogController dialog = new PopupDialogController(Activity, null, "Login"); dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_comment), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No)); } } catch (Exception exception) { Console.WriteLine(exception); } }
public static CommentData ToCommentData(CommentObject pi) { CommentData pid = new CommentData (); pid.comment = pi.commentPanel.text.text; pid.loc = pi.transform.position; pid.commentType = pi.commentPanel.commentType; return pid; }
public override void OnComment(CommentObject comment) { foreach(DocumentVisitor observer in m_observers) observer.OnComment(comment); }
//Add New Comment private async void SendButton_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(EmojiconEditTextView.Text) || string.IsNullOrWhiteSpace(EmojiconEditTextView.Text)) { return; } if (Methods.CheckConnectivity()) { CommentRecyclerView.Visibility = ViewStates.Visible; EmptyStateLayout.Visibility = ViewStates.Gone; //Comment Code string time = Methods.Time.TimeAgo(DateTime.Now); int unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; string time2 = unixTimestamp.ToString(); CommentObject comment = new CommentObject { Text = EmojiconEditTextView.Text, TimeText = time, Avatar = UserDetails.Avatar, Username = UserDetails.Username, UserId = int.Parse(UserDetails.UserId), PostId = int.Parse(PostId), Id = int.Parse(time2), IsOwner = true, Name = UserDetails.FullName, Likes = "0", Replies = 0, IsLiked = false, }; CommentsAdapter.CommentList.Add(comment); var lastItem = CommentsAdapter.CommentList.IndexOf(CommentsAdapter.CommentList.Last()); if (lastItem > -1) { CommentsAdapter.NotifyItemInserted(lastItem); CommentRecyclerView.ScrollToPosition(lastItem); } //Api request var(respondCode, respondString) = await RequestsAsync.Post.AddComment(PostId, EmojiconEditTextView.Text).ConfigureAwait(false); if (respondCode.Equals(200)) { if (respondString is AddCommentObject Object) { var dataComment = CommentsAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2)); if (dataComment != null) { dataComment.Id = Object.Id; } Activity.RunOnUiThread(() => { try { var listHome = MainContext.NewsFeedFragment?.NewsFeedAdapter?.PixelNewsFeedList; var dataPostHome = listHome?.FirstOrDefault(a => a.PostId == Convert.ToInt32(PostId)); if (dataPostHome != null) { if (dataPostHome.Votes >= 0) { dataPostHome.Votes++; } int index = listHome.IndexOf(dataPostHome); if (index >= 0) { MainContext.NewsFeedFragment.NewsFeedAdapter.NotifyItemChanged(index); } } if (FragmentName == "GifPost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (!(currentFragment is GifPostFragment frm)) { return; } frm.CommentsAdapter.CommentList = CommentsAdapter.CommentList; frm.CommentsAdapter?.NotifyDataSetChanged(); frm.CommentCount.Text = CommentsAdapter.CommentList.Count + " " + GetText(Resource.String.Lbl_Comments); } else if (FragmentName == "ImagePost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (!(currentFragment is ImagePostFragment frm)) { return; } frm.CommentsAdapter.CommentList = CommentsAdapter.CommentList; frm.CommentsAdapter?.NotifyDataSetChanged(); frm.CommentCount.Text = CommentsAdapter.CommentList.Count + " " + GetText(Resource.String.Lbl_Comments); } else if (FragmentName == "MultiImagePost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (!(currentFragment is MultiImagePostFragment frm)) { return; } frm.CommentsAdapter.CommentList = CommentsAdapter.CommentList; frm.CommentsAdapter?.NotifyDataSetChanged(); frm.CommentCount.Text = CommentsAdapter.CommentList.Count + " " + GetText(Resource.String.Lbl_Comments); } else if (FragmentName == "VideoPost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (!(currentFragment is VideoPostFragment frm)) { return; } frm.CommentsAdapter.CommentList = CommentsAdapter.CommentList; frm.CommentsAdapter?.NotifyDataSetChanged(); frm.CommentCount.Text = CommentsAdapter.CommentList.Count + " " + GetText(Resource.String.Lbl_Comments); } else if (FragmentName == "YoutubePost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (!(currentFragment is YoutubePostFragment frm)) { return; } frm.CommentsAdapter.CommentList = CommentsAdapter.CommentList; frm.CommentsAdapter?.NotifyDataSetChanged(); frm.CommentCount.Text = CommentsAdapter.CommentList.Count + " " + GetText(Resource.String.Lbl_Comments); } else if (FragmentName == "HashTags") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (currentFragment is HashTagPostFragment frm) { var listHash = frm.MAdapter.PixelNewsFeedList; var dataPostHash = listHash?.FirstOrDefault(a => a.PostId == Convert.ToInt32(PostId)); if (dataPostHash != null) { if (dataPostHash.Votes >= 0) { dataPostHash.Votes++; } int index = listHash.IndexOf(dataPostHash); if (index >= 0) { frm.MAdapter.NotifyItemChanged(index); } } } } else if (FragmentName == "NewsFeedPost") { var currentFragment = MainContext.FragmentBottomNavigator.GetSelectedTabBackStackFragment(); if (currentFragment is NewsFeedFragment frm) { var listHash = frm.NewsFeedAdapter.PixelNewsFeedList; var dataPostHash = listHash?.FirstOrDefault(a => a.PostId == Convert.ToInt32(PostId)); if (dataPostHash != null) { if (dataPostHash.Votes >= 0) { dataPostHash.Votes++; } int index = listHash.IndexOf(dataPostHash); if (index >= 0) { frm.NewsFeedAdapter.NotifyItemChanged(index); } } } } } catch (Exception exception) { Console.WriteLine(exception); } }); } } else { Methods.DisplayReportResult(Activity, respondString); } //Hide keyboard EmojiconEditTextView.Text = ""; EmojiconEditTextView.ClearFocus(); } else { Toast.MakeText(Activity, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public override void OnComment(CommentObject data) { m_comments.Add(data); }
//Add New Comment private void SendButton_Click(object sender, EventArgs e) { try { if (UserDetails.IsLogin) { if (!string.IsNullOrEmpty(EmojiconEditTextView.Text)) { if (Methods.CheckConnectivity()) { if (MAdapter.CommentList.Count == 0) { EmptyStateLayout.Visibility = ViewStates.Gone; MRecycler.Visibility = ViewStates.Visible; } //Comment Code string time = Methods.Time.TimeAgo(DateTime.Now, false); int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string time2 = unixTimestamp.ToString(); string message = EmojiconEditTextView.Text; var postId = MAdapter.CommentList.FirstOrDefault(a => a.VideoId == Convert.ToInt32(VideoId))?.PostId ?? 0; CommentObject comment = new CommentObject { Text = message, TextTime = time, UserId = Convert.ToInt32(UserDetails.UserId), Id = Convert.ToInt32(time2), IsCommentOwner = true, VideoId = Convert.ToInt32(VideoId), CommentUserData = new UserDataObject { Avatar = UserDetails.Avatar, Username = UserDetails.Username, Name = UserDetails.FullName, Cover = UserDetails.Cover }, CommentReplies = new List <ReplyObject>(), DisLikes = 0, IsDislikedComment = 0, IsLikedComment = 0, Likes = 0, Pinned = "", PostId = postId, RepliesCount = 0, Time = unixTimestamp }; MAdapter.CommentList.Add(comment); int index = MAdapter.CommentList.IndexOf(comment); MAdapter.NotifyItemInserted(index); MRecycler.ScrollToPosition(MAdapter.CommentList.IndexOf(MAdapter.CommentList.Last())); var y = MAdapter.CommentList.Count; MainContext.txtCommentNumber.Text = y.ToString(System.Globalization.CultureInfo.InvariantCulture); int index2 = MainContext.mediaList.FindIndex(x => x.Id == MainContext.selectedMedia.Id); MainContext.mediaList[index2].Comments = y.ToString(); //Api request Task.Run(async() => { using (var client = new System.Net.Http.HttpClient()) { var formContent = new System.Net.Http.FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("server_key", "0913cbbd8c729a5db4db40e4aa267a17"), new KeyValuePair <string, string>("video_id", VideoId), new KeyValuePair <string, string>("user_id", UserDetails.UserId), new KeyValuePair <string, string>("text", message), new KeyValuePair <string, string>("s", UserDetails.AccessToken) }); // send a Post request var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=add_response_comment"; var result = await client.PostAsync(uri, formContent); if (result.IsSuccessStatusCode) { // handling the answer var resultString = await result.Content.ReadAsStringAsync(); var jConfigObject = Newtonsoft.Json.Linq.JObject.Parse(resultString); if (jConfigObject["api_status"].ToString() == "200") { var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2)); if (dataComment != null) { dataComment.Id = Int32.Parse(jConfigObject["id"].ToString()); } } else { Methods.DisplayReportResult(Activity, "An unknown error occurred. Please try again later"); } } } //var (respondCode, respond) = await RequestsAsync.Comments.Add_Comment_Http(VideoId, message); //if (respondCode.Equals(200)) //{ // if (respond is MessageIdObject Object) // { // var dataComment = MAdapter.CommentList.FirstOrDefault(a => a.Id == int.Parse(time2)); // if (dataComment != null) // dataComment.Id = Object.Id; // } //} //else Methods.DisplayReportResult(Activity, respond); }); //Hide keyboard EmojiconEditTextView.Text = ""; EmojiconEditTextView.ClearFocus(); } else { Toast.MakeText(Activity, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } } else { PopupDialogController dialog = new PopupDialogController(Activity, null, "Login"); dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_comment), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No)); } } catch (Exception exception) { Console.WriteLine(exception); } }
public override void OnComment(CommentObject data) { ApplyRules(data.Content, RangeTypes.Comment); }
public void OnCommentAdded (CommentObject co) { CommentingMaster.CommentData data = CommentingMaster.ToCommentData (co); print ("Added"); print (data.comment); ParseObject po = new ParseObject ("CommentData"); po ["comment"] = data.comment; po ["position"] = "" + data.loc.x + "," + data.loc.y + "," + data.loc.z; po ["type"] = data.commentType; po ["scene"] = Application.loadedLevelName; if (co.objectId.Length > 0) po.ObjectId = co.objectId; Task task = parseMaster.StoreData (po); if (task != null) { task.ContinueWith (t => { if (t.IsFaulted || t.IsCanceled) { // The login failed. Check the error to see why. print ("save failed"); print (t.Exception); } else { // Login was successful. print ("save success"); print (po.ObjectId); co.objectId = po.ObjectId; } }); } }