protected void CreateChatRooms(){ chatroomsAdapter = new ChatRoomsAdapter (this); var chatRoomsListView = FindViewById<ListView> (Resource.Id.chatroomsListView); chatRoomsListView.Adapter = chatroomsAdapter; chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position); var intent = new Intent(this, typeof(ChatRoomActivity)); intent.PutExtra("chatroom", currChatRoom.webID); StartActivity(intent); }; chatRoomsListView.ItemLongClick += async (object sender, AdapterView.ItemLongClickEventArgs e) => { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Do you want to delete this chatroom?"); alert.SetPositiveButton("Yes", (senderAlert, args) => { ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position); ParsePush.UnsubscribeAsync (currChatRoom.webID); ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID); DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID); ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase(); pcrd.DeleteChatRoomUserAsync(cru); Console.WriteLine("ERASED"); chatroomsAdapter.NotifyDataSetChanged(); }); alert.SetNegativeButton("No", (senderAlert, args) => { }); alert.Show(); }; }
protected void CreateChatRooms() { chatroomsAdapter = new ChatRoomsAdapter(this); var chatRoomsListView = FindViewById <ListView> (Resource.Id.chatroomsListView); chatRoomsListView.Adapter = chatroomsAdapter; chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position); var intent = new Intent(this, typeof(ChatRoomActivity)); intent.PutExtra("chatroom", currChatRoom.webID); StartActivity(intent); }; chatRoomsListView.ItemLongClick += async(object sender, AdapterView.ItemLongClickEventArgs e) => { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Do you want to delete this chatroom?"); alert.SetPositiveButton("Yes", (senderAlert, args) => { ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position); ParsePush.UnsubscribeAsync(currChatRoom.webID); ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID); DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID); ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase(); pcrd.DeleteChatRoomUserAsync(cru); Console.WriteLine("ERASED"); chatroomsAdapter.NotifyDataSetChanged(); }); alert.SetNegativeButton("No", (senderAlert, args) => { }); alert.Show(); }; }
protected async Task SynchronizeWithParse(){ Console.WriteLine ("Synching"); Console.WriteLine ("sy " + DatabaseAccessors.CurrentUser ().webID); ParseChatRoomDatabase parseDB = new ParseChatRoomDatabase (); await parseDB.GetAndSyncChatRoomsAsync (); Console.WriteLine ("synched"); RunOnUiThread (() => chatroomsAdapter.NotifyDataSetChanged ()); }
protected async Task SynchronizeWithParse() { Console.WriteLine("Synching"); Console.WriteLine("sy " + DatabaseAccessors.CurrentUser().webID); ParseChatRoomDatabase parseDB = new ParseChatRoomDatabase(); await parseDB.GetAndSyncChatRoomsAsync(); Console.WriteLine("synched"); RunOnUiThread(() => chatroomsAdapter.NotifyDataSetChanged()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Contacts); Button searchContactsBtn = FindViewById <Button> (Resource.Id.search_contacts); searchContactsBtn.Click += async(sender, e) => { GetParseUsers(); contactsAdapter = new ContactsAdapter(this); var contactsListView = FindViewById <ListView> (Resource.Id.contactsListView); contactsListView.Adapter = contactsAdapter; contactsListView.ItemClick += async(object sender2, AdapterView.ItemClickEventArgs e2) => { User curritem = contactsAdapter.GetUserAt(e2.Position); ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase(); ChatRoom newchatroom = new ChatRoom(); await pcrd.SaveChatRoomAsync(newchatroom); DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoom(newchatroom); List <User> chatroomUsers = new List <User>(); chatroomUsers.Add(curritem); chatroomUsers.Add(DatabaseAccessors.CurrentUser()); DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoomUsers(chatroomUsers, newchatroom); var crus = DatabaseAccessors.ChatRoomDatabaseAccessor.GetChatRoomUsers(newchatroom.webID); foreach (ChatRoomUser cru in crus) { await pcrd.SaveChatRoomUsersAsync(cru); var push = new ParsePush(); push.Channels = new List <string> { cru.userID }; push.Alert = "Your men might be requesting help!"; await push.SendAsync(); } ChatsActivity.NotifyChatRoomsUpdate(); var intent = new Intent(this, typeof(ChatRoomActivity)); intent.PutExtra("chatroom", newchatroom.webID); StartActivity(intent); this.Finish(); }; }; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Contacts); Button searchContactsBtn = FindViewById<Button> (Resource.Id.search_contacts); searchContactsBtn.Click += async (sender, e) => { GetParseUsers(); contactsAdapter = new ContactsAdapter (this); var contactsListView = FindViewById<ListView> (Resource.Id.contactsListView); contactsListView.Adapter = contactsAdapter; contactsListView.ItemClick += async (object sender2, AdapterView.ItemClickEventArgs e2) => { User curritem = contactsAdapter.GetUserAt(e2.Position); ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase(); ChatRoom newchatroom = new ChatRoom(); await pcrd.SaveChatRoomAsync(newchatroom); DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoom(newchatroom); List<User> chatroomUsers = new List<User>(); chatroomUsers.Add(curritem); chatroomUsers.Add(DatabaseAccessors.CurrentUser()); DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoomUsers(chatroomUsers, newchatroom); var crus = DatabaseAccessors.ChatRoomDatabaseAccessor.GetChatRoomUsers(newchatroom.webID); foreach(ChatRoomUser cru in crus){ await pcrd.SaveChatRoomUsersAsync(cru); var push = new ParsePush(); push.Channels = new List<string> {cru.userID}; push.Alert = "Your men might be requesting help!"; await push.SendAsync(); } ChatsActivity.NotifyChatRoomsUpdate(); var intent = new Intent(this, typeof(ChatRoomActivity)); intent.PutExtra("chatroom", newchatroom.webID); StartActivity(intent); this.Finish(); }; }; }