//Delete Messages private void DeleteItems() { try { if (Timer != null) { Timer.Enabled = true; Timer.Start(); } if (TopChatToolBar.Visibility != ViewStates.Visible) { TopChatToolBar.Visibility = ViewStates.Visible; } if (Methods.CheckConnectivity()) { List <int> selectedItemPositions = MAdapter.GetSelectedItems(); List <int> selectedItemId = new List <int>(); for (int i = selectedItemPositions.Count - 1; i >= 0; i--) { var datItem = MAdapter.GetItem(selectedItemPositions[i]); if (datItem != null) { selectedItemId.Add(datItem.Id); MAdapter.RemoveData(selectedItemPositions[i], datItem); } } //Send Api Delete By id RequestsAsync.Messages.DeleteMessages(Userid.ToString(), selectedItemId).ConfigureAwait(false); MAdapter.NotifyDataSetChanged(); } else { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
//Copy Messages private void CopyItems() { try { if (Timer != null) { Timer.Enabled = true; Timer.Start(); } if (TopChatToolBar.Visibility != ViewStates.Visible) { TopChatToolBar.Visibility = ViewStates.Visible; } string allText = ""; List <int> selectedItemPositions = MAdapter.GetSelectedItems(); for (int i = selectedItemPositions.Count - 1; i >= 0; i--) { var datItem = MAdapter.GetItem(selectedItemPositions[i]); if (datItem != null) { allText = allText + " \n" + datItem.Text; } } ClipboardManager clipboard = (ClipboardManager)Activity.GetSystemService(ClipboardService); ClipData clip = ClipData.NewPlainText("clipboard", allText); clipboard.PrimaryClip = clip; MAdapter.NotifyDataSetChanged(); Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_Text_copied), ToastLength.Short).Show(); } catch (Exception e) { Console.WriteLine(e); } }
//Delete Chat private void DeleteItems() { try { TabbedMainActivity.GetInstance()?.SetService(); if (ToolBar.Visibility != ViewStates.Visible) { ToolBar.Visibility = ViewStates.Visible; } if (Methods.CheckConnectivity()) { List <int> selectedItemPositions = MAdapter.GetSelectedItems(); for (int i = selectedItemPositions.Count - 1; i >= 0; i--) { var datItem = MAdapter.GetItem(selectedItemPositions[i]); if (datItem != null) { MAdapter.RemoveData(selectedItemPositions[i], datItem); //Send Api Delete PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Messages.DeleteChat(datItem.Id) }); } } MAdapter.NotifyDataSetChanged(); } else { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
//Delete Chat private void DeleteItems() { try { HomeActivity.GetInstance()?.SetService(); if (ToolBar.Visibility != ViewStates.Visible) { ToolBar.Visibility = ViewStates.Visible; } if (Methods.CheckConnectivity()) { List <int> selectedItemPositions = MAdapter.GetSelectedItems(); for (int i = selectedItemPositions.Count - 1; i >= 0; i--) { var datItem = MAdapter.GetItem(selectedItemPositions[i]); if (datItem != null) { MAdapter.RemoveData(selectedItemPositions[i], datItem); //Send Api Delete RequestsAsync.Messages.DeleteChat(datItem.UserId.ToString()).ConfigureAwait(false); } } MAdapter.NotifyDataSetChanged(); } else { Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } } catch (Exception e) { Console.WriteLine(e); } }