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); } }
private async void OnUnLikeButtonClick(object sender, EventArgs e) { try { if (Methods.CheckConnectivity()) { if (UserDetails.IsLogin) { dynamic dataComments = Type == "video" ? ActivityContext?.CommentsFragment?.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id) : ShowArticleActivity.MAdapter?.CommentList?.FirstOrDefault(a => a.Id == Comment.Id); if (dataComments != null) { if (UnLikeButton.Tag.ToString() == "1") { UnLikeiconView.SetColorFilter(Color.ParseColor("#777777")); UnLikeButton.Tag = "0"; dataComments.IsDislikedComment = 0; if (!UnLikeNumber.Text.Contains("K") && !UnLikeNumber.Text.Contains("M")) { double x = Convert.ToDouble(UnLikeNumber.Text); if (x > 0) { x--; } else { x = 0; } UnLikeNumber.Text = x.ToString(CultureInfo.InvariantCulture); dataComments.DisLikes = Convert.ToInt32(x); } } else { UnLikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); UnLikeButton.Tag = "1"; dataComments.IsDislikedComment = 1; if (!UnLikeNumber.Text.Contains("K") && !UnLikeNumber.Text.Contains("M")) { double x = Convert.ToDouble(UnLikeNumber.Text); x++; UnLikeNumber.Text = x.ToString(CultureInfo.InvariantCulture); dataComments.DisLikes = Convert.ToInt32(x); } } if (LikeButton.Tag.ToString() == "1") { LikeiconView.SetColorFilter(Color.ParseColor("#777777")); LikeButton.Tag = "0"; dataComments.IsLikedComment = 0; if (!LikeNumber.Text.Contains("K") && !LikeNumber.Text.Contains("M")) { double x = Convert.ToDouble(LikeNumber.Text); if (x > 0) { x--; } else { x = 0; } LikeNumber.Text = x.ToString(CultureInfo.InvariantCulture); dataComments.Likes = Convert.ToInt32(x); } } //PollyController.RunRetryPolicyFunction(new List<Func<Task>> { () => RequestsAsync.Comments.Add_likeOrDislike_Comment_Http(dataComments.Id.ToString(), false) }); 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", "dislike"), new KeyValuePair <string, string>("reply_id", dataComments.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") { Methods.DisplayReportResult(ActivityContext, "An unknown error occurred. Please try again later"); } } } } } else { PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login"); dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Warning), ActivityContext.GetText(Resource.String.Lbl_Please_sign_in_Dislike), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No)); } } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }