private static void UpdateLastIdMessage(List <MessageData> chatMessages) { try { foreach (var messageInfo in chatMessages) { var typeModel = MainWindowActivity.MAdapter.GetTypeModel(messageInfo); if (typeModel == MessageModelType.None) { continue; } var message = WoWonderTools.MessageFilter(messageInfo.PageId, messageInfo, typeModel); message.ModelType = typeModel; var checker = MainWindowActivity?.MAdapter.DifferList?.FirstOrDefault(a => a.MesData.Id == message.MessageHashId); if (checker != null) { //checker.TypeView = typeModel; checker.MesData = message; if (AppSettings.LastChatSystem == SystemApiGetLastChat.New) { var updaterUser = GlobalContext?.LastChatTab?.MAdapter?.ChatList.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(GlobalContext.LastChatTab.MAdapter.ChatList.FirstOrDefault(x => x.PageId == message.PageId)); if (index > -1) { if (typeModel == MessageModelType.RightGif) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendGifFile); } else if (typeModel == MessageModelType.RightText) { updaterUser.LastMessage.LastMessageClass.Text = !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : GlobalContext?.GetText(Resource.String.Lbl_SendMessage); } else if (typeModel == MessageModelType.RightSticker) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendStickerFile); } else if (typeModel == MessageModelType.RightContact) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendContactnumber); } else if (typeModel == MessageModelType.RightFile) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendFile); } else if (typeModel == MessageModelType.RightVideo) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendVideoFile); } else if (typeModel == MessageModelType.RightImage) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendImageFile); } else if (typeModel == MessageModelType.RightAudio) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendAudioFile); } GlobalContext.RunOnUiThread(() => { try { GlobalContext?.LastChatTab?.MAdapter?.ChatList.Move(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemMoved(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); } catch (Exception e) { Console.WriteLine(e); } }); } } else { GlobalContext?.RunOnUiThread(() => { try { if (PageData != null) { GlobalContext?.LastChatTab.MAdapter.ChatList.Insert(0, PageData); GlobalContext?.LastChatTab.MAdapter.NotifyItemInserted(0); GlobalContext?.LastChatTab.MRecycler.ScrollToPosition(GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(PageData)); } } catch (Exception e) { Console.WriteLine(e); } }); } } else { var updaterUser = GlobalContext?.LastPageChatsTab?.MAdapter?.LastPageList.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastPageChatsTab.MAdapter.LastPageList.IndexOf(GlobalContext.LastPageChatsTab.MAdapter.LastPageList.FirstOrDefault(x => x.PageId == message.PageId)); if (index > -1) { if (typeModel == MessageModelType.RightGif) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendGifFile); } else if (typeModel == MessageModelType.RightText) { updaterUser.LastMessage.Text = !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : GlobalContext?.GetText(Resource.String.Lbl_SendMessage); } else if (typeModel == MessageModelType.RightSticker) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendStickerFile); } else if (typeModel == MessageModelType.RightContact) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendContactnumber); } else if (typeModel == MessageModelType.RightFile) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendFile); } else if (typeModel == MessageModelType.RightVideo) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendVideoFile); } else if (typeModel == MessageModelType.RightImage) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendImageFile); } else if (typeModel == MessageModelType.RightAudio) { updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendAudioFile); } GlobalContext.RunOnUiThread(() => { try { GlobalContext?.LastPageChatsTab?.MAdapter?.LastPageList.Move(index, 0); GlobalContext?.LastPageChatsTab?.MAdapter?.NotifyItemMoved(index, 0); GlobalContext?.LastPageChatsTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); } catch (Exception e) { Console.WriteLine(e); } }); } } else { GlobalContext?.RunOnUiThread(() => { try { if (DataProfilePage != null) { GlobalContext?.LastPageChatsTab?.MAdapter.LastPageList.Insert(0, DataProfilePage); GlobalContext?.LastPageChatsTab?.MAdapter.NotifyItemInserted(0); GlobalContext?.LastPageChatsTab?.MRecycler.ScrollToPosition(GlobalContext.LastPageChatsTab.MAdapter.LastPageList.IndexOf(DataProfilePage)); } } catch (Exception e) { Console.WriteLine(e); } }); } } GlobalContext?.RunOnUiThread(() => { try { //Update data RecyclerView Messages. if (message.ModelType != MessageModelType.RightSticker || message.ModelType != MessageModelType.RightImage || message.ModelType != MessageModelType.RightVideo) { MainWindowActivity.Update_One_Messeges(checker.MesData); } if (SettingsPrefFragment.SSoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Popup_SendMesseges.mp3"); } } catch (Exception e) { Console.WriteLine(e); } }); } PageData = null; DataProfilePage = null; } } catch (Exception e) { Console.WriteLine(e); } }
private static void UpdateLastIdMessage(List <MessageData> chatMessages) { try { foreach (var messageInfo in chatMessages) { var typeModel = Holders.GetTypeModel(messageInfo); if (typeModel == MessageModelType.None) { continue; } var message = WoWonderTools.MessageFilter(messageInfo.GroupId, messageInfo, typeModel); message.ModelType = typeModel; message.SendFile = false; var checker = MainWindowActivity?.MAdapter.DifferList?.FirstOrDefault(a => a.MesData.Id == message.MessageHashId); if (checker != null) { //checker.TypeView = typeModel; checker.MesData = message; checker.Id = Java.Lang.Long.ParseLong(message.Id); checker.TypeView = typeModel; checker.MesData.Id = message.Id; checker.MesData.FromId = message.FromId; checker.MesData.GroupId = message.GroupId; checker.MesData.ToId = message.ToId; checker.MesData.Text = message.Text; checker.MesData.Media = message.Media; checker.MesData.MediaFileName = message.MediaFileName; checker.MesData.MediaFileNames = message.MediaFileNames; checker.MesData.Time = message.Time; checker.MesData.Seen = message.Seen; checker.MesData.DeletedOne = message.DeletedOne; checker.MesData.DeletedTwo = message.DeletedTwo; checker.MesData.SentPush = message.SentPush; checker.MesData.NotificationId = message.NotificationId; checker.MesData.TypeTwo = message.TypeTwo; checker.MesData.Stickers = message.Stickers; checker.MesData.TimeText = message.TimeText; checker.MesData.Position = message.Position; checker.MesData.ModelType = message.ModelType; checker.MesData.FileSize = message.FileSize; checker.MesData.MediaDuration = message.MediaDuration; checker.MesData.MediaIsPlaying = message.MediaIsPlaying; checker.MesData.ContactNumber = message.ContactNumber; checker.MesData.ContactName = message.ContactName; checker.MesData.ProductId = message.ProductId; checker.MesData.MessageUser = message.MessageUser; checker.MesData.Product = message.Product; checker.MesData.MessageHashId = message.MessageHashId; checker.MesData.Lat = message.Lat; checker.MesData.Lng = message.Lng; checker.MesData.SendFile = false; if (AppSettings.LastChatSystem == SystemApiGetLastChat.New) { var updaterUser = GlobalContext?.LastChatTab?.MAdapter?.ChatList.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(GlobalContext.LastChatTab.MAdapter.ChatList.FirstOrDefault(x => x.GroupId == message.GroupId)); if (index > -1) { if (typeModel == MessageModelType.RightGif) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendGifFile); } else if (typeModel == MessageModelType.RightText) { updaterUser.LastMessage.LastMessageClass.Text = !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : GlobalContext?.GetText(Resource.String.Lbl_SendMessage); } else if (typeModel == MessageModelType.RightSticker) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendStickerFile); } else if (typeModel == MessageModelType.RightContact) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendContactnumber); } else if (typeModel == MessageModelType.RightFile) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendFile); } else if (typeModel == MessageModelType.RightVideo) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendVideoFile); } else if (typeModel == MessageModelType.RightImage) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendImageFile); } else if (typeModel == MessageModelType.RightAudio) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendAudioFile); } else if (typeModel == MessageModelType.RightMap) { updaterUser.LastMessage.LastMessageClass.Text = GlobalContext?.GetText(Resource.String.Lbl_SendLocationFile); } GlobalContext.RunOnUiThread(() => { try { GlobalContext?.LastChatTab?.MAdapter?.ChatList.Move(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemMoved(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); } catch (Exception e) { Console.WriteLine(e); } }); } } else { GlobalContext?.RunOnUiThread(() => { try { if (GroupData != null) { GlobalContext?.LastChatTab.MAdapter.ChatList.Insert(0, GroupData); GlobalContext?.LastChatTab.MAdapter.NotifyItemInserted(0); GlobalContext?.LastChatTab.MRecycler.ScrollToPosition(GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(GroupData)); } } catch (Exception e) { Console.WriteLine(e); } }); } } else { var updaterUser = GlobalContext?.LastGroupChatsTab?.MAdapter?.LastGroupList.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastGroupChatsTab.MAdapter.LastGroupList.IndexOf(GlobalContext.LastGroupChatsTab.MAdapter.LastGroupList.FirstOrDefault(x => x.GroupId == message.GroupId)); if (index > -1) { //if (typeModel == MessageModelType.RightGif) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendGifFile); //else if (typeModel == MessageModelType.RightText) // updaterUser.LastMessage.Text = !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : GlobalContext?.GetText(Resource.String.Lbl_SendMessage); //else if (typeModel == MessageModelType.RightSticker) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendStickerFile); //else if (typeModel == MessageModelType.RightContact) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendContactnumber); //else if (typeModel == MessageModelType.RightFile) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendFile); //else if (typeModel == MessageModelType.RightVideo) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendVideoFile); //else if (typeModel == MessageModelType.RightImage) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendImageFile); //else if (typeModel == MessageModelType.RightAudio) // updaterUser.LastMessage.Text = GlobalContext?.GetText(Resource.String.Lbl_SendAudioFile); //GlobalContext.RunOnUiThread(() => //{ // try // { // GlobalContext?.LastGroupChatsTab?.MAdapter?.LastGroupList.Move(index, 0); // GlobalContext?.LastGroupChatsTab?.MAdapter?.NotifyItemMoved(index, 0); // GlobalContext?.LastGroupChatsTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); // } // catch (Exception e) // { // Console.WriteLine(e); // } //}); } } else { //GlobalContext?.RunOnUiThread(() => //{ // try // { // GlobalContext?.LastGroupChatsTab?.MAdapter.LastGroupList.Insert(0, GroupData); // GlobalContext?.LastGroupChatsTab?.MAdapter.NotifyItemInserted(0); // GlobalContext?.LastGroupChatsTab?.MRecycler.ScrollToPosition(GlobalContext.LastGroupChatsTab.MAdapter.LastGroupList.IndexOf(GroupData)); // } // catch (Exception e) // { // Console.WriteLine(e); // } //}); } } GlobalContext?.RunOnUiThread(() => { try { //Update data RecyclerView Messages. if (message.ModelType != MessageModelType.RightSticker || message.ModelType != MessageModelType.RightImage || message.ModelType != MessageModelType.RightMap || message.ModelType != MessageModelType.RightVideo) { MainWindowActivity.Update_One_Messeges(checker.MesData); } if (SettingsPrefFragment.SSoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Popup_SendMesseges.mp3"); } } catch (Exception e) { Console.WriteLine(e); } }); } GroupData = null; } } catch (Exception e) { Console.WriteLine(e); } }
public static void UpdateLastIdMessage(SendMessageObject chatMessages) { try { foreach (var messageInfo in chatMessages.MessageData) { MessageData m = new MessageData { Id = messageInfo.Id, FromId = messageInfo.FromId, GroupId = messageInfo.GroupId, ToId = messageInfo.ToId, Text = messageInfo.Text, Media = messageInfo.Media, MediaFileName = messageInfo.MediaFileName, MediaFileNames = messageInfo.MediaFileNames, Time = messageInfo.Time, Seen = messageInfo.Seen, DeletedOne = messageInfo.DeletedOne, DeletedTwo = messageInfo.DeletedTwo, SentPush = messageInfo.SentPush, NotificationId = messageInfo.NotificationId, TypeTwo = messageInfo.TypeTwo, Stickers = messageInfo.Stickers, TimeText = messageInfo.TimeText, Position = messageInfo.Position, ModelType = messageInfo.ModelType, FileSize = messageInfo.FileSize, MediaDuration = messageInfo.MediaDuration, MediaIsPlaying = messageInfo.MediaIsPlaying, ContactNumber = messageInfo.ContactNumber, ContactName = messageInfo.ContactName, ProductId = messageInfo.ProductId, MessageUser = messageInfo.MessageUser, Product = messageInfo.Product, MessageHashId = messageInfo.MessageHashId, Lat = messageInfo.Lat, Lng = messageInfo.Lng, SendFile = false, }; var typeModel = Holders.GetTypeModel(m); if (typeModel == MessageModelType.None) { continue; } var message = WoWonderTools.MessageFilter(messageInfo.ToId, m, typeModel, true); message.ModelType = typeModel; AdapterModelsClassUser checker = WindowActivity?.MAdapter?.DifferList?.FirstOrDefault(a => a.MesData.Id == messageInfo.MessageHashId); if (checker != null) { //checker.TypeView = typeModel; checker.MesData = message; checker.Id = Java.Lang.Long.ParseLong(message.Id); checker.TypeView = typeModel; checker.MesData.Id = message.Id; checker.MesData.FromId = message.FromId; checker.MesData.GroupId = message.GroupId; checker.MesData.ToId = message.ToId; checker.MesData.Text = message.Text; checker.MesData.Media = message.Media; checker.MesData.MediaFileName = message.MediaFileName; checker.MesData.MediaFileNames = message.MediaFileNames; checker.MesData.Time = message.Time; checker.MesData.Seen = message.Seen; checker.MesData.DeletedOne = message.DeletedOne; checker.MesData.DeletedTwo = message.DeletedTwo; checker.MesData.SentPush = message.SentPush; checker.MesData.NotificationId = message.NotificationId; checker.MesData.TypeTwo = message.TypeTwo; checker.MesData.Stickers = message.Stickers; checker.MesData.TimeText = message.TimeText; checker.MesData.Position = message.Position; checker.MesData.ModelType = message.ModelType; checker.MesData.FileSize = message.FileSize; checker.MesData.MediaDuration = message.MediaDuration; checker.MesData.MediaIsPlaying = message.MediaIsPlaying; checker.MesData.ContactNumber = message.ContactNumber; checker.MesData.ContactName = message.ContactName; checker.MesData.ProductId = message.ProductId; checker.MesData.MessageUser = message.MessageUser; checker.MesData.Product = message.Product; checker.MesData.MessageHashId = message.MessageHashId; checker.MesData.Lat = message.Lat; checker.MesData.Lng = message.Lng; checker.MesData.SendFile = false; if (AppSettings.LastChatSystem == SystemApiGetLastChat.New) { var updaterUser = GlobalContext?.LastChatTab?.MAdapter?.ChatList?.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(GlobalContext.LastChatTab.MAdapter.ChatList.FirstOrDefault(x => x.UserId == message.ToId)); if (index > -1) { updaterUser.LastMessage.LastMessageClass.Text = typeModel switch { MessageModelType.RightGif => WindowActivity?.GetText(Resource.String.Lbl_SendGifFile), MessageModelType.RightText => !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : WindowActivity?.GetText(Resource.String.Lbl_SendMessage), MessageModelType.RightSticker => WindowActivity?.GetText(Resource.String.Lbl_SendStickerFile), MessageModelType.RightContact => WindowActivity?.GetText(Resource.String.Lbl_SendContactnumber), MessageModelType.RightFile => WindowActivity?.GetText(Resource.String.Lbl_SendFile), MessageModelType.RightVideo => WindowActivity?.GetText(Resource.String.Lbl_SendVideoFile), MessageModelType.RightImage => WindowActivity?.GetText(Resource.String.Lbl_SendImageFile), MessageModelType.RightAudio => WindowActivity?.GetText(Resource.String.Lbl_SendAudioFile), MessageModelType.RightMap => WindowActivity?.GetText(Resource.String.Lbl_SendLocationFile), _ => updaterUser.LastMessage.LastMessageClass.Text }; GlobalContext.RunOnUiThread(() => { try { GlobalContext?.LastChatTab?.MAdapter?.ChatList.Move(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemMoved(index, 0); GlobalContext?.LastChatTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); } catch (Exception e) { Console.WriteLine(e); } }); SqLiteDatabase dbSqLite = new SqLiteDatabase(); //Update All data users to database dbSqLite.Insert_Or_Update_LastUsersChat(GlobalContext, new ObservableCollection <ChatObject>() { updaterUser }); dbSqLite.Dispose(); } } else { //insert new user var data = ConvertData(checker.MesData); if (data != null) { GlobalContext?.RunOnUiThread(() => { try { GlobalContext?.LastChatTab.MAdapter.ChatList.Insert(0, data); GlobalContext?.LastChatTab.MAdapter.NotifyItemInserted(0); GlobalContext?.LastChatTab.MRecycler.ScrollToPosition(GlobalContext.LastChatTab.MAdapter.ChatList.IndexOf(data)); } catch (Exception e) { Console.WriteLine(e); } }); //Update All data users to database //dbDatabase.Insert_Or_Update_LastUsersChat(new ObservableCollection<GetUsersListObject.User> //{ // data //}); } } } else { var updaterUser = GlobalContext?.LastMessagesTab?.MAdapter?.MLastMessagesUser?.FirstOrDefault(a => a.UserId == message.ToId); if (updaterUser != null) { var index = GlobalContext.LastMessagesTab.MAdapter.MLastMessagesUser.IndexOf(GlobalContext.LastMessagesTab.MAdapter.MLastMessagesUser.FirstOrDefault(x => x.UserId == message.ToId)); if (index > -1) { updaterUser.LastMessage.Text = typeModel switch { MessageModelType.RightGif => WindowActivity?.GetText(Resource.String.Lbl_SendGifFile), MessageModelType.RightText => !string.IsNullOrEmpty(message.Text) ? Methods.FunString.DecodeString(message.Text) : WindowActivity?.GetText(Resource.String.Lbl_SendMessage), MessageModelType.RightSticker => WindowActivity?.GetText(Resource.String.Lbl_SendStickerFile), MessageModelType.RightContact => WindowActivity?.GetText(Resource.String.Lbl_SendContactnumber), MessageModelType.RightFile => WindowActivity?.GetText(Resource.String.Lbl_SendFile), MessageModelType.RightVideo => WindowActivity?.GetText(Resource.String.Lbl_SendVideoFile), MessageModelType.RightImage => WindowActivity?.GetText(Resource.String.Lbl_SendImageFile), MessageModelType.RightAudio => WindowActivity?.GetText(Resource.String.Lbl_SendAudioFile), MessageModelType.RightMap => WindowActivity?.GetText(Resource.String.Lbl_SendLocationFile), _ => updaterUser.LastMessage.Text }; GlobalContext.RunOnUiThread(() => { try { GlobalContext?.LastMessagesTab?.MAdapter?.MLastMessagesUser.Move(index, 0); GlobalContext?.LastMessagesTab?.MAdapter?.NotifyItemMoved(index, 0); GlobalContext?.LastMessagesTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob"); } catch (Exception e) { Console.WriteLine(e); } }); SqLiteDatabase dbSqLite = new SqLiteDatabase(); //Update All data users to database dbSqLite.Insert_Or_Update_LastUsersChat(GlobalContext, new ObservableCollection <GetUsersListObject.User>() { updaterUser }); dbSqLite.Dispose(); } } else { //insert new user var data = ConvertDataChat(checker.MesData); if (data != null) { GlobalContext?.RunOnUiThread(() => { try { GlobalContext?.LastMessagesTab?.MAdapter.MLastMessagesUser.Insert(0, data); GlobalContext?.LastMessagesTab?.MAdapter.NotifyItemInserted(0); GlobalContext?.LastMessagesTab?.MRecycler.ScrollToPosition(GlobalContext.LastMessagesTab.MAdapter.MLastMessagesUser.IndexOf(data)); } catch (Exception e) { Console.WriteLine(e); } }); //Update All data users to database //dbDatabase.Insert_Or_Update_LastUsersChat(new ObservableCollection<GetUsersListObject.User> //{ // data //}); } } } //checker.Media = media; //Update All data users to database SqLiteDatabase dbDatabase = new SqLiteDatabase(); dbDatabase.Insert_Or_Update_To_one_MessagesTable(checker.MesData); dbDatabase.Dispose(); GlobalContext?.RunOnUiThread(() => { try { //Update data RecyclerView Messages. if (message.ModelType != MessageModelType.RightSticker || message.ModelType != MessageModelType.RightImage || message.ModelType != MessageModelType.RightMap || message.ModelType != MessageModelType.RightVideo) { WindowActivity?.Update_One_Messages(checker.MesData); } if (SettingsPrefFragment.SSoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Popup_SendMesseges.mp3"); } } catch (Exception e) { Console.WriteLine(e); } }); } } Datauser = null; DataUserChat = null; UserData = null; } 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 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()) }); } else if (TypeClass == "Reply") { //TypeClass var adapterGlobal = ReplyCommentBottomSheet.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()) }); } 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); } }
public static void UpdateRecyclerLastMessageView(GetUsersListObject.LastMessage result, GetUsersListObject.User user, int index, TabbedMainActivity context) { try { if (IsImageExtension(result.MediaFileName)) { result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendImageFile); } else if (IsVideoExtension(result.MediaFileName)) { result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendVideoFile); } else if (IsAudioExtension(result.MediaFileName)) { result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendAudioFile); } else if (IsFileExtension(result.MediaFileName)) { result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendFile); } else if (result.MediaFileName.Contains(".gif") || result.MediaFileName.Contains(".GIF")) { result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendGifFile); } else { result.Text = Methods.FunString.DecodeString(result.Text); } context.RunOnUiThread(() => { try { switch (AppSettings.LastChatSystem) { case SystemApiGetLastChat.New: context.LastChatTab?.MAdapter?.NotifyItemChanged(index); break; default: context.LastMessagesTab?.MAdapter?.NotifyItemChanged(index); break; } } catch (Exception e) { Console.WriteLine(e); } }); SqLiteDatabase dbDatabase = new SqLiteDatabase(); //Update All data users to database dbDatabase.Insert_Or_Update_LastUsersChat(GlobalContext, new ObservableCollection <GetUsersListObject.User>() { user }); dbDatabase.Dispose(); } catch (Exception e) { Console.WriteLine(e); } }