//Report / Delete / Copy comment private void MAdapterOnOnItemLongClick(object sender, CommentAdapterClickEventArgs e) { try { var position = e.Position; if (position > -1) { ItemComments = MAdapter.GetItem(position); if (ItemComments != null) { var arrayAdapter = new List <string>(); var dialogList = new MaterialDialog.Builder(ActivityContext).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); if (UserDetails.IsLogin) { arrayAdapter.Add(ActivityContext.GetText(Resource.String.Lbl_Report)); } if (ItemComments.Owner && UserDetails.IsLogin) { arrayAdapter.Add(ActivityContext.GetText(Resource.String.Lbl_Delete)); } arrayAdapter.Add(ActivityContext.GetText(Resource.String.Lbl_Copy)); dialogList.Items(arrayAdapter); dialogList.PositiveText(ActivityContext.GetText(Resource.String.Lbl_Close)).OnPositive(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); } } } catch (Exception exception) { Console.WriteLine(exception); } }
private async void SendButtonOnClick(object sender, EventArgs e) { try { if (!UserDetails.IsLogin) { PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login"); dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Login), ActivityContext.GetText(Resource.String.Lbl_Message_Sorry_signin), ActivityContext.GetText(Resource.String.Lbl_Yes), ActivityContext.GetText(Resource.String.Lbl_No)); return; } if (string.IsNullOrEmpty(EmojisIconEditTextView.Text)) { return; } if (Methods.CheckConnectivity()) { EmptyStateLayout.Visibility = ViewStates.Gone; //Comment Code string time = Methods.Time.TimeAgo(DateTime.Now); UnixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; CommentsDataObject comment = new CommentsDataObject { Id = UnixTimestamp, TrackId = DataObject.Id, UserId = UserDetails.UserId, Value = EmojisIconEditTextView.Text, Songseconds = 0, Songpercentage = 0, Time = UnixTimestamp, Posted = time, SecondsFormated = TimeComment, Owner = true, UserData = ListUtils.MyUserInfoList.FirstOrDefault(), IsLikedComment = false, CountLiked = 0, }; MAdapter.CommentList.Add(comment); var index = MAdapter.CommentList.IndexOf(comment); if (index > -1) { MAdapter.NotifyItemInserted(index); } MRecycler.Visibility = ViewStates.Visible; EmptyStateLayout.Visibility = ViewStates.Gone; (int apiStatus, var respond) = await RequestsAsync.Comments.CreateCommentAsync(DataObject.AudioId, TimeComment, EmojisIconEditTextView.Text).ConfigureAwait(false); if (apiStatus == 200) { if (respond is CreateCommentObject result) { var date = MAdapter.CommentList.FirstOrDefault(a => a.Id == UnixTimestamp); if (date != null) { date.Id = result.Data.CommentId; index = MAdapter.CommentList.IndexOf(comment); if (index > -1) { ActivityContext.RunOnUiThread(() => { try { MAdapter.NotifyItemChanged(index); MRecycler.ScrollToPosition(index); } catch (Exception exception) { Console.WriteLine(exception); } }); } } Console.WriteLine(date); } } else { Methods.DisplayReportResult(ActivityContext, respond); } //Hide keyboard EmojisIconEditTextView.Text = ""; EmojisIconEditTextView.ClearFocus(); } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }