//Api sent Comment private async void ImgSentOnClick(object sender, EventArgs e) { try { IsRecording = false; if (BtnVoice.Tag?.ToString() == "Audio") { var interTortola = new FastOutSlowInInterpolator(); TopFragment.Animate().SetInterpolator(interTortola).TranslationY(1200).SetDuration(300); SupportFragmentManager.BeginTransaction().Remove(RecordSoundFragment).Commit(); PathVoice = RecorderService.GetRecorded_Sound_Path(); } if (string.IsNullOrEmpty(TxtComment.Text) && string.IsNullOrEmpty(PathImage) && string.IsNullOrEmpty(PathVoice)) { return; } if (Methods.CheckConnectivity()) { var dataUser = ListUtils.MyProfileList.FirstOrDefault(); //Comment Code var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string time2 = unixTimestamp.ToString(CultureInfo.InvariantCulture); CommentObjectExtra comment = new CommentObjectExtra { Id = unixTimestamp.ToString(), PostId = PostObject.Id, UserId = UserDetails.UserId, Text = TxtComment.Text, Time = time2, CFile = PathImage, Record = PathVoice, Publisher = dataUser, Url = dataUser?.Url, Fullurl = PostObject?.PostUrl, Orginaltext = TxtComment.Text, Owner = true, CommentLikes = "0", CommentWonders = "0", IsCommentLiked = false, Replies = "0" }; MAdapter.CommentList.Add(comment); var index = MAdapter.CommentList.IndexOf(comment); if (index > -1) { MAdapter.NotifyItemInserted(index); } MRecycler.Visibility = ViewStates.Visible; var dd = MAdapter.CommentList.FirstOrDefault(); if (dd?.Text == MAdapter.EmptyState) { MAdapter.CommentList.Remove(dd); MAdapter.NotifyItemRemoved(MAdapter.CommentList.IndexOf(dd)); } ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost)); var text = TxtComment.Text; //Hide keyboard TxtComment.Text = ""; (int apiStatus, var respond) = await RequestsAsync.Comment.CreatePostComments(PostObject.PostId, text, PathImage, PathVoice); if (apiStatus == 200) { if (respond is CreateComments result) { var date = MAdapter.CommentList.FirstOrDefault(a => a.Id == comment.Id) ?? MAdapter.CommentList.FirstOrDefault(x => x.Id == result.Data.Id); if (date != null) { var db = Mapper.Map <CommentObjectExtra>(result.Data); date = db; date.Id = result.Data.Id; index = MAdapter.CommentList.IndexOf(MAdapter.CommentList.FirstOrDefault(a => a.Id == unixTimestamp.ToString())); if (index > -1) { MAdapter.CommentList[index] = db; //MAdapter.NotifyItemChanged(index); //MRecycler.ScrollToPosition(index); } var postFeedAdapter = TabbedMainActivity.GetInstance()?.NewsFeedTab?.PostFeedAdapter; var dataGlobal = postFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList(); if (dataGlobal?.Count > 0) { foreach (var dataClass in from dataClass in dataGlobal let indexCom = postFeedAdapter.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString(); if (dataClass.PostData.GetPostComments?.Count > 0) { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); if (dataComment == null) { dataClass.PostData.GetPostComments.Add(date); } } else { dataClass.PostData.GetPostComments = new List <GetCommentObject>() { date }; } postFeedAdapter.NotifyItemChanged(postFeedAdapter.ListDiffer.IndexOf(dataClass), "commentReplies"); } } var postFeedAdapter2 = WRecyclerView.GetInstance()?.NativeFeedAdapter; var dataGlobal2 = postFeedAdapter2?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList(); if (dataGlobal2?.Count > 0) { foreach (var dataClass in from dataClass in dataGlobal2 let indexCom = postFeedAdapter2.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString(); if (dataClass.PostData.GetPostComments?.Count > 0) { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); if (dataComment == null) { dataClass.PostData.GetPostComments.Add(date); } } else { dataClass.PostData.GetPostComments = new List <GetCommentObject>() { date }; } postFeedAdapter2.NotifyItemChanged(postFeedAdapter2.ListDiffer.IndexOf(dataClass), "commentReplies"); } } } } } //else Methods.DisplayReportResult(this, respond); //Hide keyboard TxtComment.Text = ""; PathImage = ""; PathVoice = ""; BtnVoice.Tag = "Free"; BtnVoice.SetImageResource(Resource.Drawable.microphone); BtnVoice.ClearColorFilter(); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public void OnClick(MaterialDialog p0, DialogAction p1) { try { if (DialogType == "Delete") { if (p1 == DialogAction.Positive) { // Send Api delete if (Methods.CheckConnectivity()) { var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter; var diff = adapterGlobal?.ListDiffer; var dataGlobal = diff?.Where(a => a.PostData?.PostId == DataInfoObject?.PostId); if (dataGlobal != null) { foreach (var postData in dataGlobal) { WRecyclerView.GetInstance()?.RemoveByRowIndex(postData); } } var recycler = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView; var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.PostId == DataInfoObject?.PostId); if (dataGlobal2 != null) { foreach (var postData in dataGlobal2) { recycler.RemoveByRowIndex(postData); } } var dataJob = JobList?.FirstOrDefault(a => a.Id == DataInfoObject.Id); if (dataJob != null) { JobList.Remove(dataJob); NotifyItemRemoved(JobsActivity.GetInstance().MAdapter.JobList.IndexOf(dataJob)); } Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short).Show(); PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Post_Actions(DataInfoObject.PostId, "delete") }); } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } else { if (p1 == DialogAction.Positive) { } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } } catch (Exception e) { Console.WriteLine(e); } }
//Api sent Comment private async void ImgSentOnClick(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(TxtComment.Text) && string.IsNullOrEmpty(PathImage)) { return; } if (Methods.CheckConnectivity()) { CommentObject.Replies ??= "0"; //Comment Code var dataUser = ListUtils.MyProfileList.FirstOrDefault(); var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); CommentObjectExtra comment = new CommentObjectExtra { Id = unixTimestamp.ToString(), PostId = CommentObject.PostId, UserId = UserDetails.UserId, Text = TxtComment.Text, Time = unixTimestamp.ToString(), CFile = PathImage, Record = "", Publisher = dataUser, Url = dataUser?.Url, Fullurl = CommentObject?.Fullurl, Orginaltext = TxtComment.Text, Owner = true, CommentLikes = "0", CommentWonders = "0", IsCommentLiked = false, Replies = "0" }; MAdapter.ReplyCommentList.Add(comment); var index = MAdapter.ReplyCommentList.IndexOf(comment); if (index > -1) { MAdapter.NotifyItemInserted(index); } MainRecyclerView.Visibility = ViewStates.Visible; var dd = MAdapter.ReplyCommentList.FirstOrDefault(); if (dd?.Text == MAdapter.EmptyState) { MAdapter.ReplyCommentList.Remove(dd); MAdapter.NotifyItemRemoved(MAdapter.ReplyCommentList.IndexOf(dd)); } //CommentLayout.Visibility = ViewStates.Gone; bool success = int.TryParse(CommentObject.Replies, out var number); if (success) { Console.WriteLine("Converted '{0}' to {1}.", CommentObject.Replies, number); var x = number + 1; ReplyCountTextView.Text = x + " " + GetString(Resource.String.Lbl_Replies); } else { Console.WriteLine("Attempted conversion of '{0}' failed.", CommentObject.Replies ?? "<null>"); ReplyCountTextView.Text = 1 + " " + GetString(Resource.String.Lbl_Replies); } ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost)); var text = TxtComment.Text; //Hide keyboard TxtComment.Text = ""; (int apiStatus, var respond) = await RequestsAsync.Comment.CreatePostComments(CommentId, text, PathImage, "", "create_reply"); if (apiStatus == 200) { if (respond is CreateComments result) { var date = MAdapter.ReplyCommentList.FirstOrDefault(a => a.Id == comment.Id) ?? MAdapter.ReplyCommentList.FirstOrDefault(x => x.Id == result.Data.Id); if (date != null) { var db = Mapper.Map <CommentObjectExtra>(result.Data); date = db; date.Id = result.Data.Id; index = MAdapter.ReplyCommentList.IndexOf(MAdapter.ReplyCommentList.FirstOrDefault(a => a.Id == unixTimestamp.ToString())); if (index > -1) { MAdapter.ReplyCommentList[index] = db; //MAdapter.NotifyItemChanged(index, !string.IsNullOrEmpty(PathImage) ? 1 : 0); //MainRecyclerView.ScrollToPosition(index); } var postFeedAdapter = WRecyclerView.GetInstance()?.NativeFeedAdapter; var dataGlobal = postFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == CommentObject?.PostId).ToList(); if (dataGlobal?.Count > 0) { foreach (var dataClass in from dataClass in dataGlobal let indexCom = postFeedAdapter.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { if (dataClass.PostData.GetPostComments?.Count > 0) { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); if (dataComment != null) { dataComment.Replies = MAdapter.ReplyCommentList.Count.ToString(); } } postFeedAdapter.NotifyItemChanged(postFeedAdapter.ListDiffer.IndexOf(dataClass)); } } } } } else { Methods.DisplayReportResult(this, respond); } //Hide keyboard TxtComment.Text = ""; PathImage = ""; } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public async void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString) { try { string text = itemString.ToString(); if (text == GetString(Resource.String.Btn_Paypal)) { InitPayPalPayment.BtnPaypalOnClick(CodeName, "Funding"); } else if (text == GetString(Resource.String.Btn_GooglePlay)) { BillingPayment.SetConnInAppBilling(); BillingPayment.InitInAppBilling(CodeName, "Funding", ""); } else if (text == GetString(Resource.String.Lbl_CreditCard)) { OpenIntentCreditCard(); } else if (text == GetString(Resource.String.Lbl_BankTransfer)) { OpenIntentBankTransfer(); } else if (text == GetString(Resource.String.Lbl_RazorPay)) { InitRazorPay?.BtnRazorPayOnClick(CodeName, "Funding", ""); } else if (text == GetString(Resource.String.Lbl_PayStack)) { DialogType = "PayStack"; var dialog = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light); dialog.Title(Resource.String.Lbl_PayStack); dialog.Input(Resource.String.Lbl_Email, 0, false, async(materialDialog, s) => { try { if (s.Length <= 0) { return; } var check = Methods.FunString.IsEmailValid(s.ToString().Replace(" ", "")); if (!check) { Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), GetText(Resource.String.Lbl_IsEmailValid), GetText(Resource.String.Lbl_Ok)); return; } Toast.MakeText(this, GetText(Resource.String.Lbl_Please_wait), ToastLength.Short)?.Show(); await PayStack(s.ToString()); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }); dialog.InputType(InputTypes.TextVariationEmailAddress); dialog.PositiveText(GetText(Resource.String.Lbl_PayNow)).OnPositive(this); dialog.NegativeText(GetText(Resource.String.Lbl_Cancel)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.Build().Show(); } else if (text == GetString(Resource.String.Lbl_CashFree)) { OpenCashFreeDialog(); } else if (text == GetString(Resource.String.Lbl_PaySera)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_wait), ToastLength.Short)?.Show(); await PaySera(); } else if (text == GetString(Resource.String.Lbl_Share)) { ShareEvent(); } else if (text == GetString(Resource.String.Lbl_Edit)) { EditEvent(); } else if (text == GetString(Resource.String.Lbl_Copy)) { CopyLinkEvent(); } else if (text == GetString(Resource.String.Lbl_Delete)) { DialogType = "Delete"; var dialog = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light); dialog.Title(Resource.String.Lbl_Warning); dialog.Content(GetText(Resource.String.Lbl_DeleteFunding)); dialog.PositiveText(GetText(Resource.String.Lbl_Yes)).OnPositive((materialDialog, action) => { try { // Send Api delete if (Methods.CheckConnectivity()) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Funding.DeleteFunding(DataObject.Id) }); var instance = FundingActivity.GetInstance(); var dataFunding = instance?.FundingTab?.MAdapter?.FundingList?.FirstOrDefault(a => a.Id == DataObject.Id); if (dataFunding != null) { instance?.FundingTab?.MAdapter?.FundingList.Remove(dataFunding); instance.FundingTab?.MAdapter?.NotifyItemRemoved(instance.FundingTab.MAdapter.FundingList.IndexOf(dataFunding)); } var dataMyFunding = instance?.MyFundingTab?.MAdapter?.FundingList?.FirstOrDefault(a => a.Id == DataObject.Id); if (dataMyFunding != null) { instance?.MyFundingTab?.MAdapter?.FundingList.Remove(dataMyFunding); instance.MyFundingTab?.MAdapter?.NotifyItemRemoved(instance.MyFundingTab.MAdapter.FundingList.IndexOf(dataMyFunding)); } var recycler = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView; var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.FundId == DataObject.Id).ToList(); if (dataGlobal2 != null) { foreach (var postData in dataGlobal2) { recycler.RemoveByRowIndex(postData); } } var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter; var diff = adapterGlobal?.ListDiffer; var dataGlobal = diff?.Where(a => a.PostData?.FundId == DataObject.Id).ToList(); if (dataGlobal != null) { foreach (var postData in dataGlobal) { WRecyclerView.GetInstance()?.RemoveByRowIndex(postData); } } Toast.MakeText(this, GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short)?.Show(); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }); dialog.NegativeText(GetText(Resource.String.Lbl_No)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.ItemsCallback(this).Build().Show(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString) { try { string text = itemString.ToString(); if (text == GetString(Resource.String.Btn_Paypal)) { InitPayPalPayment.BtnPaypalOnClick(DataObject.Amount); } else if (text == GetString(Resource.String.Btn_GooglePlay)) { BillingPayment.SetConnInAppBilling(); BillingPayment.InitInAppBilling(DataObject.Amount, "Funding", ""); } else if (text == GetString(Resource.String.Lbl_CreditCard)) { OpenIntentCreditCard(); } else if (text == GetString(Resource.String.Lbl_BankTransfer)) { OpenIntentBankTransfer(); } else if (text == GetString(Resource.String.Lbl_Share)) { ShareEvent(); } else if (text == GetString(Resource.String.Lbl_Edit)) { EditEvent(); } else if (text == GetString(Resource.String.Lbl_Copy)) { CopyLinkEvent(); } else if (text == GetString(Resource.String.Lbl_Delete)) { DialogType = "Delete"; var dialog = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light); dialog.Title(Resource.String.Lbl_Warning); dialog.Content(GetText(Resource.String.Lbl_DeleteFunding)); dialog.PositiveText(GetText(Resource.String.Lbl_Yes)).OnPositive((materialDialog, action) => { try { // Send Api delete if (Methods.CheckConnectivity()) { var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter; var diff = adapterGlobal?.ListDiffer; var dataGlobal = diff?.Where(a => a.PostData?.FundId == DataObject.Id); if (dataGlobal != null) { foreach (var postData in dataGlobal) { WRecyclerView.GetInstance()?.RemoveByRowIndex(postData); } } var recycler = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView; var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.FundId == DataObject.Id); if (dataGlobal2 != null) { foreach (var postData in dataGlobal2) { recycler.RemoveByRowIndex(postData); } } var dataFunding = FundingActivity.GetInstance()?.MAdapter?.FundingList?.FirstOrDefault(a => a.Id == DataObject.Id); if (dataFunding != null) { FundingActivity.GetInstance()?.MAdapter?.FundingList.Remove(dataFunding); FundingActivity.GetInstance().MAdapter.NotifyItemRemoved(FundingActivity.GetInstance().MAdapter.FundingList.IndexOf(dataFunding)); } Toast.MakeText(this, GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short).Show(); PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Funding.DeleteFunding(DataObject.Id) }); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }); dialog.NegativeText(GetText(Resource.String.Lbl_No)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.ItemsCallback(this).Build().Show(); } } 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, MainContext.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } else { if (TypeClass == "Comment") { //TypeClass var adapterGlobal = CommentActivity.GetInstance()?.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 dataPost = WRecyclerView.GetInstance()?.NativeFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == CommentObject.PostId).ToList(); if (dataPost?.Count > 0) { foreach (var post in dataPost) { if (post.TypeView != PostModelType.CommentSection) { continue; } var dataComment = post.PostData.GetPostComments?.FirstOrDefault(a => a.Id == CommentObject?.Id); if (dataComment != null) { dataComment.Text = strName; var index = post.PostData.GetPostComments.IndexOf(dataComment); if (index > -1) { WRecyclerView.GetInstance()?.NativeFeedAdapter.NotifyItemChanged(index); } } } } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.EditCommentAsync(CommentObject.Id, strName) }); } else if (TypeClass == "Reply") { //TypeClass var adapterGlobal = ReplyCommentActivity.GetInstance()?.MAdapter; var dataGlobal = adapterGlobal?.ReplyCommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); if (dataGlobal != null) { dataGlobal.Text = strName; var index = adapterGlobal.ReplyCommentList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.NotifyItemChanged(index); } } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.EditCommentAsync(CommentObject.Id, strName, "edit_reply") }); } } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void OnClick(MaterialDialog p0, DialogAction p1) { try { if (DialogType == "Delete") { if (p1 == DialogAction.Positive) { // Send Api delete if (Methods.CheckConnectivity()) { var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter; var diff = adapterGlobal?.ListDiffer; var dataGlobal = diff?.Where(a => a.PostData?.OfferId == DataInfoObject?.Id).ToList(); if (dataGlobal != null) { foreach (var postData in dataGlobal) { WRecyclerView.GetInstance()?.RemoveByRowIndex(postData); } } var recycler = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView; var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.OfferId == DataInfoObject?.Id).ToList(); if (dataGlobal2 != null) { foreach (var postData in dataGlobal2) { recycler.RemoveByRowIndex(postData); } } Toast.MakeText(this, GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short)?.Show(); PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Offers.DeleteOffer(DataInfoObject.Id) }); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); } } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } else { if (p1 == DialogAction.Positive) { } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void OnClick(MaterialDialog p0, DialogAction p1) { try { if (p1 == DialogAction.Positive) { if (TypeDialog == "DeleteComment") { MainContext.RunOnUiThread(() => { try { switch (TypeClass) { case "Comment": { //TypeClass var adapterGlobal = CommentActivity.GetInstance()?.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 dataPost = TabbedMainActivity.GetInstance()?.NewsFeedTab?.PostFeedAdapter?.ListDiffer?.Where(a => a.PostData?.PostId == CommentObject?.PostId).ToList(); if (dataPost?.Count > 0) { foreach (var post in dataPost.Where(post => post.TypeView == PostModelType.CommentSection || post.TypeView == PostModelType.AddCommentSection)) { TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView?.RemoveByRowIndex(post); } } var dataPost2 = WRecyclerView.GetInstance()?.NativeFeedAdapter?.ListDiffer?.Where(a => a.PostData?.PostId == CommentObject?.PostId).ToList(); if (dataPost2?.Count > 0) { foreach (var post in dataPost2.Where(post => post.TypeView == PostModelType.CommentSection || post.TypeView == PostModelType.AddCommentSection)) { WRecyclerView.GetInstance()?.RemoveByRowIndex(post); } } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.DeleteCommentAsync(CommentObject.Id) }); break; } case "Reply": { //TypeClass var adapterGlobal = ReplyCommentActivity.GetInstance()?.MAdapter; var dataGlobal = adapterGlobal?.ReplyCommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id); if (dataGlobal != null) { var index = adapterGlobal.ReplyCommentList.IndexOf(dataGlobal); if (index > -1) { adapterGlobal.ReplyCommentList.RemoveAt(index); adapterGlobal.NotifyItemRemoved(index); } } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Comment.DeleteCommentAsync(CommentObject.Id, "delete_reply") }); break; } } Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CommentSuccessfullyDeleted), ToastLength.Short)?.Show(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }); } else { if (p1 == DialogAction.Positive) { } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void OnClick(MaterialDialog p0, DialogAction p1) { try { if (TypeDialog == "DeletePost") { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); return; } var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter; var diff = adapterGlobal?.ListDiffer; var dataGlobal = diff?.Where(a => a.PostData?.PostId == ProductData?.PostId).ToList(); if (dataGlobal != null) { foreach (var postData in dataGlobal) { WRecyclerView.GetInstance()?.RemoveByRowIndex(postData); } } var recycler = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView; var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.PostId == ProductData?.PostId).ToList(); if (dataGlobal2 != null) { foreach (var postData in dataGlobal2) { recycler.RemoveByRowIndex(postData); } } if (TabbedMarketActivity.GetInstance()?.MyProductsTab?.MAdapter?.MarketList != null) { TabbedMarketActivity.GetInstance().MyProductsTab.MAdapter.MarketList?.Remove(ProductData); TabbedMarketActivity.GetInstance().MyProductsTab.MAdapter.NotifyDataSetChanged(); } if (TabbedMarketActivity.GetInstance()?.MarketTab?.MAdapter?.MarketList != null) { TabbedMarketActivity.GetInstance().MarketTab.MAdapter.MarketList?.Remove(ProductData); TabbedMarketActivity.GetInstance().MarketTab.MAdapter.NotifyDataSetChanged(); } Toast.MakeText(this, GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short)?.Show(); PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Post_Actions(ProductData.PostId, "delete") }); Finish(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } } else { if (p1 == DialogAction.Positive) { } else if (p1 == DialogAction.Negative) { p0.Dismiss(); } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
// Insert Post //===================================== private void InsertOnTopAutoSection(bool isSharing = false) { try { if (isSharing) { var getSharedPostType = PostFunctions.GetAdapterType(PostCollection.SharedInfo.SharedInfoClass); var collection = PostCollection.SharedInfo.SharedInfoClass; switch (getSharedPostType) { case PostModelType.BlogPost: PostModelResolver.PrepareBlog(collection); break; case PostModelType.EventPost: PostModelResolver.PrepareEvent(collection); if (Convert.ToInt32(collection.EventId) > 0) { return; } break; case PostModelType.ColorPost: PostModelResolver.PrepareColorBox(collection); break; case PostModelType.LinkPost: PostModelResolver.PrepareLink(collection); break; case PostModelType.ProductPost: PostModelResolver.PrepareProduct(collection); break; case PostModelType.FundingPost: PostModelResolver.PrepareFunding(collection); break; case PostModelType.OfferPost: PostModelResolver.PrepareOffer(collection); break; case PostModelType.MapPost: PostModelResolver.PrepareMapPost(collection); break; case PostModelType.PollPost: case PostModelType.AdsPost: case PostModelType.AdMob: case PostModelType.FbAdNative: return; case PostModelType.VideoPost: WRecyclerView.GetInstance()?.CacheVideosFiles(Uri.Parse(collection.PostFileFull)); break; case PostModelType.JobPost: AddJobPost(); return; } var item = new AdapterModelsClass { TypeView = getSharedPostType, Id = int.Parse((int)getSharedPostType + collection.Id), PostData = collection, IsDefaultFeedPost = true }; CountIndex++; PostList.Insert(CountIndex, item); } else { switch (PostFeedType) { case PostModelType.BlogPost: PostModelResolver.PrepareBlog(PostCollection); break; case PostModelType.EventPost: PostModelResolver.PrepareEvent(PostCollection); if (Convert.ToInt32(PostCollection.EventId) > 0) { return; } break; case PostModelType.ColorPost: PostModelResolver.PrepareColorBox(PostCollection); break; case PostModelType.LinkPost: PostModelResolver.PrepareLink(PostCollection); break; case PostModelType.ProductPost: PostModelResolver.PrepareProduct(PostCollection); break; case PostModelType.FundingPost: PostModelResolver.PrepareFunding(PostCollection); break; case PostModelType.OfferPost: PostModelResolver.PrepareOffer(PostCollection); break; case PostModelType.MapPost: PostModelResolver.PrepareMapPost(PostCollection); break; case PostModelType.PollPost: case PostModelType.AdsPost: case PostModelType.AdMob: case PostModelType.FbAdNative: return; case PostModelType.VideoPost: WRecyclerView.GetInstance()?.CacheVideosFiles(Uri.Parse(PostCollection.PostFileFull)); break; case PostModelType.JobPost: AddJobPost(); return; case PostModelType.SharedPost: InsertOnTopSharedPost(); return; } var item = new AdapterModelsClass { TypeView = PostFeedType, Id = int.Parse((int)PostFeedType + PostCollection.Id), PostData = PostCollection, IsDefaultFeedPost = true, PostDataDecoratedContent = TextDecorator.SetupStrings(PostCollection, MainContext), }; CountIndex++; PostList.Insert(CountIndex, item); } } catch (Exception e) { Console.WriteLine(e); } }
//Api sent Comment private async void ImgSentOnClick(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(TxtComment.Text) && string.IsNullOrWhiteSpace(TxtComment.Text) && string.IsNullOrEmpty(PathImage)) { return; } if (Methods.CheckConnectivity()) { CommentObject.Replies ??= "0"; CommentObject.RepliesCount ??= "0"; //Comment Code var dataUser = ListUtils.MyProfileList?.FirstOrDefault(); var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); CommentObjectExtra comment = new CommentObjectExtra { Id = unixTimestamp.ToString(), PostId = CommentObject.PostId, UserId = UserDetails.UserId, Text = TxtComment.Text, Time = unixTimestamp.ToString(), CFile = PathImage, Record = "", Publisher = dataUser, Url = dataUser?.Url, Fullurl = CommentObject?.Fullurl, Orginaltext = TxtComment.Text, Owner = true, CommentLikes = "0", CommentWonders = "0", IsCommentLiked = false, Replies = "0", RepliesCount = "0", }; MAdapter.ReplyCommentList.Add(comment); var index = MAdapter.ReplyCommentList.IndexOf(comment); switch (index) { case > -1: MAdapter.NotifyItemInserted(index); break; } MRecycler.Visibility = ViewStates.Visible; var dd = MAdapter.ReplyCommentList.FirstOrDefault(); if (dd?.Text == MAdapter.EmptyState) { MAdapter.ReplyCommentList.Remove(dd); MAdapter.NotifyItemRemoved(MAdapter.ReplyCommentList.IndexOf(dd)); } var repliesCount = !string.IsNullOrEmpty(CommentObject.RepliesCount) ? CommentObject.RepliesCount : CommentObject.Replies ?? ""; //CommentLayout.Visibility = ViewStates.Gone; bool success = int.TryParse(repliesCount, out var number); switch (success) { case true: { Console.WriteLine("Converted '{0}' to {1}.", repliesCount, number); var x = number + 1; ReplyCountTextView.Text = x + " " + GetString(Resource.String.Lbl_Replies); break; } default: Console.WriteLine("Attempted conversion of '{0}' failed.", repliesCount ?? "<null>"); ReplyCountTextView.Text = 1 + " " + GetString(Resource.String.Lbl_Replies); break; } ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost)); var text = TxtComment.Text; //Hide keyboard TxtComment.Text = ""; var(apiStatus, respond) = await RequestsAsync.Comment.CreatePostCommentsAsync(CommentId, text, PathImage, "", "create_reply"); switch (apiStatus) { case 200: { switch (respond) { case CreateComments result: { var date = MAdapter.ReplyCommentList.FirstOrDefault(a => a.Id == comment.Id) ?? MAdapter.ReplyCommentList.FirstOrDefault(x => x.Id == result.Data.Id); if (date != null) { var db = ClassMapper.Mapper?.Map <CommentObjectExtra>(result.Data); date = db; date.Id = result.Data.Id; index = MAdapter.ReplyCommentList.IndexOf(MAdapter.ReplyCommentList.FirstOrDefault(a => a.Id == unixTimestamp.ToString())); MAdapter.ReplyCommentList[index] = index switch { > -1 => db, _ => MAdapter.ReplyCommentList[index] }; var commentAdapter = CommentActivity.GetInstance()?.MAdapter; var commentObject = commentAdapter?.CommentList?.FirstOrDefault(a => a.Id == CommentId); if (commentObject != null) { commentObject.Replies = commentAdapter.CommentList.Count.ToString(); commentObject.RepliesCount = commentAdapter.CommentList.Count.ToString(); commentAdapter.NotifyDataSetChanged(); } var postFeedAdapter = TabbedMainActivity.GetInstance()?.NewsFeedTab?.PostFeedAdapter; var dataGlobal = postFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == CommentObject?.PostId).ToList(); switch (dataGlobal?.Count) { case > 0: { foreach (var dataClass in from dataClass in dataGlobal let indexCom = postFeedAdapter.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { switch (dataClass.PostData.GetPostComments?.Count) { case > 0: { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); if (dataComment != null) { dataComment.Replies = MAdapter.ReplyCommentList.Count.ToString(); dataComment.RepliesCount = MAdapter.ReplyCommentList.Count.ToString(); } break; } } postFeedAdapter.NotifyItemChanged(postFeedAdapter.ListDiffer.IndexOf(dataClass), "commentReplies"); } break; } } var postFeedAdapter2 = WRecyclerView.GetInstance()?.NativeFeedAdapter; var dataGlobal1 = postFeedAdapter2?.ListDiffer?.Where(a => a.PostData?.Id == CommentObject?.PostId).ToList(); switch (dataGlobal1?.Count) { case > 0: { foreach (var dataClass in from dataClass in dataGlobal1 let indexCom = postFeedAdapter2.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { switch (dataClass.PostData.GetPostComments?.Count) { case > 0: { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); if (dataComment != null) { dataComment.Replies = MAdapter.ReplyCommentList.Count.ToString(); dataComment.RepliesCount = MAdapter.ReplyCommentList.Count.ToString(); } break; } } postFeedAdapter2.NotifyItemChanged(postFeedAdapter2.ListDiffer.IndexOf(dataClass), "commentReplies"); } break; } } } break; } } break; } }
//Api sent Comment private async void ImgSentOnClick(object sender, EventArgs e) { try { IsRecording = false; switch (BtnVoice.Tag?.ToString()) { case "Audio": { var interTortola = new FastOutSlowInInterpolator(); TopFragment.Animate()?.SetInterpolator(interTortola)?.TranslationY(1200)?.SetDuration(300); SupportFragmentManager.BeginTransaction().Remove(RecordSoundFragment)?.Commit(); PathVoice = RecorderService.GetRecorded_Sound_Path(); break; } } if (string.IsNullOrEmpty(TxtComment.Text) && string.IsNullOrWhiteSpace(TxtComment.Text) && string.IsNullOrEmpty(PathImage) && string.IsNullOrEmpty(PathVoice)) { return; } if (Methods.CheckConnectivity()) { var dataUser = ListUtils.MyProfileList?.FirstOrDefault(); //Comment Code var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string time2 = unixTimestamp.ToString(CultureInfo.InvariantCulture); CommentObjectExtra comment = new CommentObjectExtra { Id = unixTimestamp.ToString(), PostId = PostObject.Id, UserId = UserDetails.UserId, Text = TxtComment.Text, Time = time2, CFile = PathImage, Record = PathVoice, Publisher = dataUser, Url = dataUser?.Url, Fullurl = PostObject?.PostUrl, Orginaltext = TxtComment.Text, Owner = true, CommentLikes = "0", CommentWonders = "0", IsCommentLiked = false, Replies = "0", RepliesCount = "0" }; MAdapter.CommentList.Add(comment); var index = MAdapter.CommentList.IndexOf(comment); switch (index) { case > -1: MAdapter.NotifyItemInserted(index); break; } MRecycler.Visibility = ViewStates.Visible; var dd = MAdapter.CommentList.FirstOrDefault(); if (dd?.Text == MAdapter.EmptyState) { MAdapter.CommentList.Remove(dd); MAdapter.NotifyItemRemoved(MAdapter.CommentList.IndexOf(dd)); } ImgGallery.SetImageDrawable(AppSettings.SetTabDarkTheme ? GetDrawable(Resource.Drawable.ic_action_addpost_Ligth) : GetDrawable(Resource.Drawable.ic_action_AddPost)); var text = TxtComment.Text; //Hide keyboard TxtComment.Text = ""; var(apiStatus, respond) = await RequestsAsync.Comment.CreatePostCommentsAsync(PostObject.PostId, text, PathImage, PathVoice); switch (apiStatus) { case 200: { switch (respond) { case CreateComments result: { var date = MAdapter.CommentList.FirstOrDefault(a => a.Id == comment.Id) ?? MAdapter.CommentList.FirstOrDefault(x => x.Id == result.Data.Id); if (date != null) { var db = ClassMapper.Mapper?.Map <CommentObjectExtra>(result.Data); date = db; date.Id = result.Data.Id; index = MAdapter.CommentList.IndexOf(MAdapter.CommentList.FirstOrDefault(a => a.Id == unixTimestamp.ToString())); MAdapter.CommentList[index] = index switch { > -1 => db, _ => MAdapter.CommentList[index] }; var postFeedAdapter = TabbedMainActivity.GetInstance()?.NewsFeedTab?.PostFeedAdapter; var dataGlobal = postFeedAdapter?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList(); switch (dataGlobal?.Count) { case > 0: { foreach (var dataClass in from dataClass in dataGlobal let indexCom = postFeedAdapter.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString(); switch (dataClass.PostData.GetPostComments?.Count) { case > 0: { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); switch (dataComment) { case null: dataClass.PostData.GetPostComments.Add(date); break; } break; } default: dataClass.PostData.GetPostComments = new List <GetCommentObject> { date }; break; } postFeedAdapter.NotifyItemChanged(postFeedAdapter.ListDiffer.IndexOf(dataClass), "commentReplies"); } break; } } var postFeedAdapter2 = WRecyclerView.GetInstance()?.NativeFeedAdapter; var dataGlobal2 = postFeedAdapter2?.ListDiffer?.Where(a => a.PostData?.Id == PostObject?.PostId).ToList(); switch (dataGlobal2?.Count) { case > 0: { foreach (var dataClass in from dataClass in dataGlobal2 let indexCom = postFeedAdapter2.ListDiffer.IndexOf(dataClass) where indexCom > -1 select dataClass) { dataClass.PostData.PostComments = MAdapter.CommentList.Count.ToString(); switch (dataClass.PostData.GetPostComments?.Count) { case > 0: { var dataComment = dataClass.PostData.GetPostComments.FirstOrDefault(a => a.Id == date.Id); switch (dataComment) { case null: dataClass.PostData.GetPostComments.Add(date); break; } break; } default: dataClass.PostData.GetPostComments = new List <GetCommentObject> { date }; break; } postFeedAdapter2.NotifyItemChanged(postFeedAdapter2.ListDiffer.IndexOf(dataClass), "commentReplies"); } break; } } } break; } } break; } }