void OnClick(Holders.LastMessagesClickEventArgs args) => ItemClick?.Invoke(this, args);
//Call Swipe Item private void MAdapterOnCallItemClick(object sender, Holders.LastMessagesClickEventArgs e) { try { var position = e.Position; if (position >= 0) { var item = MAdapter.GetItem(position); if (item != null) { DataUserChat = item; string timeNow = DateTime.Now.ToString("hh:mm"); var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string time = Convert.ToString(unixTimestamp); if (AppSettings.EnableAudioCall && AppSettings.EnableVideoCall) { var arrayAdapter = new List <string>(); var dialogList = new MaterialDialog.Builder(Context).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); arrayAdapter.Add(Context.GetText(Resource.String.Lbl_Voice_call)); arrayAdapter.Add(Context.GetText(Resource.String.Lbl_Video_call)); dialogList.Title(GetText(Resource.String.Lbl_Call)); //dialogList.Content(GetText(Resource.String.Lbl_Select_Type_Call)); dialogList.Items(arrayAdapter); dialogList.PositiveText(GetText(Resource.String.Lbl_Close)).OnPositive(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); } else if (AppSettings.EnableAudioCall == false && AppSettings.EnableVideoCall) // Video Call On { try { Intent intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); if (AppSettings.UseAgoraLibrary && AppSettings.UseTwilioLibrary == false) { intentVideoCall = new Intent(Context, typeof(AgoraVideoCallActivity)); intentVideoCall.PutExtra("type", "Agora_video_calling_start"); } else if (AppSettings.UseAgoraLibrary == false && AppSettings.UseTwilioLibrary) { intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); intentVideoCall.PutExtra("type", "Twilio_video_calling_start"); } intentVideoCall.PutExtra("UserID", item.UserId); intentVideoCall.PutExtra("avatar", item.Avatar); intentVideoCall.PutExtra("name", item.Name); intentVideoCall.PutExtra("time", timeNow); intentVideoCall.PutExtra("CallID", time); intentVideoCall.PutExtra("access_token", "YOUR_TOKEN"); intentVideoCall.PutExtra("access_token_2", "YOUR_TOKEN"); intentVideoCall.PutExtra("from_id", "0"); intentVideoCall.PutExtra("active", "0"); intentVideoCall.PutExtra("status", "0"); intentVideoCall.PutExtra("room_name", "TestRoom"); StartActivity(intentVideoCall); } catch (Exception exception) { Console.WriteLine(exception); } } else if (AppSettings.EnableAudioCall && AppSettings.EnableVideoCall == false) // Audio Call On { try { Intent intentVideoCall = new Intent(Context, typeof(TwilioVideoCallActivity)); if (AppSettings.UseAgoraLibrary && AppSettings.UseTwilioLibrary == false) { intentVideoCall = new Intent(Context, typeof(AgoraAudioCallActivity)); intentVideoCall.PutExtra("type", "Agora_audio_calling_start"); } else if (AppSettings.UseAgoraLibrary == false && AppSettings.UseTwilioLibrary) { intentVideoCall = new Intent(Context, typeof(TwilioAudioCallActivity)); intentVideoCall.PutExtra("type", "Twilio_audio_calling_start"); } intentVideoCall.PutExtra("UserID", item.UserId); intentVideoCall.PutExtra("avatar", item.Avatar); intentVideoCall.PutExtra("name", item.Name); intentVideoCall.PutExtra("time", timeNow); intentVideoCall.PutExtra("CallID", time); intentVideoCall.PutExtra("access_token", "YOUR_TOKEN"); intentVideoCall.PutExtra("access_token_2", "YOUR_TOKEN"); intentVideoCall.PutExtra("from_id", "0"); intentVideoCall.PutExtra("active", "0"); intentVideoCall.PutExtra("status", "0"); intentVideoCall.PutExtra("room_name", "TestRoom"); StartActivity(intentVideoCall); } catch (Exception exception) { Console.WriteLine(exception); } } } } } catch (Exception exception) { Console.WriteLine(exception); } }
private void MAdapterOnItemClick(object sender, Holders.LastMessagesClickEventArgs e) { try { var position = e.Position; if (position >= 0) { var item = MAdapter.GetItem(position); if (item != null) { UserId = item.UserId; Activity.RunOnUiThread(() => { if (item.LastMessage.ToId == UserDetails.UserId && item.LastMessage.FromId != UserDetails.UserId) { item.LastMessage.Seen = "1"; MAdapter.NotifyItemChanged(position); } }); if (item.ChatColor == null) { item.ChatColor = AppSettings.MainColor; } var mainChatColor = item.ChatColor.Contains("rgb") ? Methods.FunString.ConvertColorRgBtoHex(item.ChatColor) : item.ChatColor ?? AppSettings.MainColor; Intent intent = new Intent(Context, typeof(ChatWindowActivity)); intent.PutExtra("UserID", item.UserId); intent.PutExtra("TypeChat", "LastMessenger"); intent.PutExtra("ShowEmpty", "no"); intent.PutExtra("ColorChat", mainChatColor); intent.PutExtra("UserItem", JsonConvert.SerializeObject(item)); // Check if we're running on Android 5.0 or higher if ((int)Build.VERSION.SdkInt < 23) { StartActivity(intent); } else { //Check to see if any permission in our group is available, if one, then all are if (Context.CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Granted && Context.CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Granted) { StartActivity(intent); } else { RequestPermissions(new[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage }, 101); } } } } } catch (Exception exception) { Console.WriteLine(exception); } }
//Delete Swipe Item private void MAdapterOnDeleteItemClick(object sender, Holders.LastMessagesClickEventArgs e) { try { var position = e.Position; if (position >= 0) { var item = MAdapter.GetItem(position); if (item != null) { var dialog = new MaterialDialog.Builder(Context).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); dialog.Title(GetText(Resource.String.Lbl_DeleteTheEntireConversation)); dialog.Content(GetText(Resource.String.Lbl_OnceYouDeleteConversation)); dialog.PositiveText(GetText(Resource.String.Lbl_Yes)).OnPositive((materialDialog, action) => { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } var userToDelete = MAdapter.MLastMessagesUser.FirstOrDefault(a => a.UserId == item.UserId); if (userToDelete != null) { MAdapter.ItemsSwiped.Swiped = false; MAdapter.ItemsSwiped = null; var index = MAdapter.MLastMessagesUser.IndexOf(userToDelete); if (index > -1) { MAdapter.MLastMessagesUser.Remove(userToDelete); MAdapter.NotifyItemRemoved(index); } } var dbDatabase = new SqLiteDatabase(); dbDatabase.Delete_LastUsersChat(item.UserId); dbDatabase.DeleteAllMessagesUser(UserDetails.UserId, item.UserId); dbDatabase.Dispose(); PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Delete_Conversation(item.UserId) }); Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_TheConversationHasBeenDeleted), ToastLength.Long).Show(); } catch (Exception exception) { Console.WriteLine(exception); } }); dialog.NegativeText(GetText(Resource.String.Lbl_No)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.Build().Show(); } } } catch (Exception exception) { Console.WriteLine(exception); } }