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") { ActivityContext = LatestResponsePlayerActivity.GetInstance(); } InitComponent(contentView); SetRecyclerViewAdapters(); CommentClickListener = new ResponseCommentClickListener(ActivityContext, "Reply"); SendButton.Click += SendButton_Click; LikeButton.Click += OnLikeButtonClick; UnLikeButton.Click += OnUnLikeButtonClick; UnLikeButton.Visibility = ViewStates.Gone; LoadReplies(); } catch (Exception e) { Console.WriteLine(e); } }
public void OnInput(MaterialDialog p0, ICharSequence p1) { try { if (p1.Length() > 0) { var strName = p1.ToString(); if (!Methods.CheckConnectivity()) { Toast.MakeText(MainContext, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } else { if (TypeClass == "Comment") { //TypeClass var adapterGlobal = MainContext?.CommentsFragment?.MAdapter; var dataGlobal = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); if (dataGlobal != null) { dataGlobal.Text = strName; var index = adapterGlobal.CommentList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.NotifyItemChanged(index); } } //var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter; //var dataGlobal1 = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); //if (dataGlobal1 != null) //{ // dataGlobal1.Text = strName; // var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1); // if (index > -1) // { // adapterGlobal1.NotifyItemChanged(index); // } //} //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Edit_Comment_Http(CommentObject.Id.ToString(), strName) }); 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>("type", "edit"), new KeyValuePair <string, string>("comment_id", CommentObject.Id.ToString()), new KeyValuePair <string, string>("text", strName), new KeyValuePair <string, string>("user_id", UserDetails.UserId), new KeyValuePair <string, string>("s", UserDetails.AccessToken) }); // send a Post request var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments"; 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") { } } } }); } else if (TypeClass == "Reply") { //TypeClass var adapterGlobal = AdminReplyCommentBottomSheet.GetInstance()?.ReplyAdapter; var dataGlobal = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id); if (dataGlobal != null) { dataGlobal.Text = strName; var index = adapterGlobal.ReplyList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.NotifyItemChanged(index); } } //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Edit_Comment_Reply_Http(ReplyObject.Id.ToString(), strName) }); 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>("type", "edit"), new KeyValuePair <string, string>("reply_id", ReplyObject.Id.ToString()), new KeyValuePair <string, string>("text", strName), new KeyValuePair <string, string>("user_id", UserDetails.UserId), new KeyValuePair <string, string>("s", UserDetails.AccessToken) }); // send a Post request var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments"; 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") { } } } }); } } } } catch (Exception e) { Console.WriteLine(e); } }
public void OnClick(MaterialDialog p0, DialogAction p1) { try { if (p1 == DialogAction.Positive) { if (TypeDialog == "DeleteComment") { MainContext.RunOnUiThread(() => { try { if (TypeClass == "Comment") { //TypeClass var adapterGlobal = MainContext?.CommentsFragment?.MAdapter; var dataGlobal = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); if (dataGlobal != null) { var index = adapterGlobal.CommentList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.CommentList.RemoveAt(index); adapterGlobal.NotifyItemRemoved(index); var y = adapterGlobal.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(); } } //var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter; //var dataGlobal1 = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); //if (dataGlobal1 != null) //{ // var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1); // if (index > -1) // { // adapterGlobal1.CommentList.RemoveAt(index); // adapterGlobal1.NotifyItemRemoved(index); // } //} //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Delete_Comment_Http(CommentObject.Id.ToString()) }); 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>("type", "delete"), new KeyValuePair <string, string>("comment_id", CommentObject.Id.ToString()), new KeyValuePair <string, string>("user_id", UserDetails.UserId), new KeyValuePair <string, string>("s", UserDetails.AccessToken) }); // send a Post request var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments"; 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") { //int index = MainContext.mediaList.FindIndex(x => x.RvId == MainContext.selectedMedia.RvId); //var y = Convert.ToDouble(MainContext.mediaList[index].Comments); //if (y > 0) y--; //else y = 0; //MainContext.txtCommentNumber.Text = y.ToString(System.Globalization.CultureInfo.InvariantCulture); //MainContext.mediaList[index].Comments = y.ToString(); } } } }); } else if (TypeClass == "Reply") { //TypeClass var adapterGlobal = AdminReplyCommentBottomSheet.GetInstance()?.ReplyAdapter; var dataGlobal = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id); if (dataGlobal != null) { var index = adapterGlobal.ReplyList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.ReplyList.RemoveAt(index); adapterGlobal.NotifyItemRemoved(index); } } //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Delete_Reply_Http(ReplyObject.Id.ToString()) }); 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>("type", "delete"), new KeyValuePair <string, string>("reply_id", ReplyObject.Id.ToString()), new KeyValuePair <string, string>("user_id", UserDetails.UserId), new KeyValuePair <string, string>("s", UserDetails.AccessToken) }); // send a Post request var uri = PlayTubeClient.Client.WebsiteUrl + "/api/v1.0/?type=response_comments"; 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") { //int index = MainContext.mediaList.FindIndex(x => x.RvId == MainContext.selectedMedia.RvId); //var y = Convert.ToDouble(MainContext.mediaList[index].Comments); //if (y > 0) y--; //else y = 0; //MainContext.txtCommentNumber.Text = y.ToString(System.Globalization.CultureInfo.InvariantCulture); //MainContext.mediaList[index].Comments = y.ToString(); } } } }); } Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CommentSuccessfullyDeleted), ToastLength.Short).Show(); } catch (Exception e) { Console.WriteLine(e); } }); } else { if (p1 == DialogAction.Positive) { } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } catch (Exception e) { Console.WriteLine(e); } }