SlideShare a Scribd company logo
Creating a WhatsApp Clone - Part X
The final part discussing the client side code covers the NewMessageForm class
public class NewMessageForm extends Form {
public NewMessageForm() {
super("Select Contact", BoxLayout.y());
Form current = getCurrentForm();
getToolbar().setBackCommand("", e -> current.showBack());
MultiButton newGroup = new MultiButton("New group");
MultiButton newContact = new MultiButton("New contact");
FontImage.setMaterialIcon(newGroup,
FontImage.MATERIAL_GROUP_ADD, 3.5f);
FontImage.setMaterialIcon(newContact,
FontImage.MATERIAL_PERSON_ADD, 3.5f);
add(newGroup);
add(newContact);
Server.fetchContacts(lst -> {
for(ChatContact c : lst) {
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
NewMessageForm
NewMessageForm is a form we see when we press the floating action button in the main form
public class NewMessageForm extends Form {
public NewMessageForm() {
super("Select Contact", BoxLayout.y());
Form current = getCurrentForm();
getToolbar().setBackCommand("", e -> current.showBack());
MultiButton newGroup = new MultiButton("New group");
MultiButton newContact = new MultiButton("New contact");
FontImage.setMaterialIcon(newGroup,
FontImage.MATERIAL_GROUP_ADD, 3.5f);
FontImage.setMaterialIcon(newContact,
FontImage.MATERIAL_PERSON_ADD, 3.5f);
add(newGroup);
add(newContact);
Server.fetchContacts(lst -> {
for(ChatContact c : lst) {
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
NewMessageForm
This class is trivial by comparison to the previous class. It’s just a box layout Y form that lets us pick the contact we wish to chat with
public NewMessageForm() {
super("Select Contact", BoxLayout.y());
Form current = getCurrentForm();
getToolbar().setBackCommand("", e -> current.showBack());
MultiButton newGroup = new MultiButton("New group");
MultiButton newContact = new MultiButton("New contact");
FontImage.setMaterialIcon(newGroup,
FontImage.MATERIAL_GROUP_ADD, 3.5f);
FontImage.setMaterialIcon(newContact,
FontImage.MATERIAL_PERSON_ADD, 3.5f);
add(newGroup);
add(newContact);
Server.fetchContacts(lst -> {
for(ChatContact c : lst) {
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
NewMessageForm
The new group and contact buttons aren’t currently mapped to anything. They are just simple buttons.
FontImage.MATERIAL_GROUP_ADD, 3.5f);
FontImage.setMaterialIcon(newContact,
FontImage.MATERIAL_PERSON_ADD, 3.5f);
add(newGroup);
add(newContact);
Server.fetchContacts(lst -> {
for(ChatContact c : lst) {
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
NewMessageForm
We use the fetch contacts method to fetch the list of contacts to show here
add(newGroup);
add(newContact);
Server.fetchContacts(lst -> {
for(ChatContact c : lst) {
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
NewMessageForm
For every contact in the list of contacts we create a multi button matching the name and icon.
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
NewMessageForm
If a contact is clicked we check if he has an ID. If not this is someone that might not be in the app yet. So we need to contact the server and check.
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
NewMessageForm
findRegisteredUser finds the specific user based on his phone number
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
NewMessageForm
If we get null as a result it means there is no such registered user in the app. We go back to the previous form and show a toastbar message there
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
NewMessageForm
If there is we update the user id and save
MultiButton mb = new MultiButton(c.name.get());
mb.setTextLine2(c.tagline.get());
mb.setIcon(c.getSmallIcon());
c.photo.addChangeListener(p ->
mb.setIcon(c.getSmallIcon()));
mb.addActionListener(e -> {
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
NewMessageForm
We can then launch the chat form with this new contact
if(c.id.get() == null) {
Server.findRegisteredUser(
c.phone.get(), contact -> {
if(contact == null) {
current.showBack();
callSerially(() ->
ToastBar.showErrorMessage(
"Contact isn't registered"));
return;
}
c.id.set(contact.id.get());
Server.saveContacts();
});
return;
}
new ChatForm(c, current).show();
});
add(mb);
}
revalidate();
});
}
}
NewMessageForm
Since all the multibuttons are added asynchronously we need to revalidate so they will show on the form. As I said this is a super simple short class and with that we
finished the client side work…

More Related Content

PDF
Creating a Whatsapp Clone - Part X.pdf
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IX.pdf
PDF
Creating a Whatsapp Clone - Part V - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part V.pdf
PDF
Creating an Uber - Part VI - Transcript.pdf
Creating a Whatsapp Clone - Part X.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part V.pdf
Creating an Uber - Part VI - Transcript.pdf

Similar to Creating a Whatsapp Clone - Part X - Transcript.pdf (19)

PDF
How do I - Create a List of Items - Transcript.pdf
PDF
Creating a Facebook Clone - Part VI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXVIII.pdf
PDF
Creating a Facebook Clone - Part XXX - Transcript.pdf
PDF
Creating a Facebook Clone - Part VIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXX.pdf
PDF
Creating a Whatsapp Clone - Part II.pdf
PDF
Creating a Facebook Clone - Part XVI - Transcript.pdf
PDF
Java Svet - Communication Between Android App Components
PDF
Java Svet - Communication Between Android App Components
PDF
Creating a Facebook Clone - Part XLVI - Transcript.pdf
PDF
Creating an Uber Clone - Part XIV - Transcript.pdf
PDF
Creating a Facebook Clone - Part VI.pdf
PDF
Creating a Facebook Clone - Part XXXIII - Transcript.pdf
PDF
GWT architecture best practices and lessons learned
PDF
How do I - Create a List of Items.pdf
PDF
Creating a Whatsapp Clone - Part XI - Transcript.pdf
PDF
Creating a Facebook Clone - Part VIII.pdf
PDF
Creating a Facebook Clone - Part VII.pdf
How do I - Create a List of Items - Transcript.pdf
Creating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXX - Transcript.pdf
Creating a Facebook Clone - Part VIII - Transcript.pdf
Creating a Facebook Clone - Part XXX.pdf
Creating a Whatsapp Clone - Part II.pdf
Creating a Facebook Clone - Part XVI - Transcript.pdf
Java Svet - Communication Between Android App Components
Java Svet - Communication Between Android App Components
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating an Uber Clone - Part XIV - Transcript.pdf
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part XXXIII - Transcript.pdf
GWT architecture best practices and lessons learned
How do I - Create a List of Items.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Facebook Clone - Part VIII.pdf
Creating a Facebook Clone - Part VII.pdf

More from ShaiAlmog1 (20)

PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
PDF
create-netflix-clone-06-client-ui.pdf
PDF
create-netflix-clone-01-introduction_transcript.pdf
PDF
create-netflix-clone-02-server_transcript.pdf
PDF
create-netflix-clone-04-server-continued_transcript.pdf
PDF
create-netflix-clone-01-introduction.pdf
PDF
create-netflix-clone-06-client-ui_transcript.pdf
PDF
create-netflix-clone-03-server.pdf
PDF
create-netflix-clone-04-server-continued.pdf
PDF
create-netflix-clone-05-client-model_transcript.pdf
PDF
create-netflix-clone-03-server_transcript.pdf
PDF
create-netflix-clone-02-server.pdf
PDF
create-netflix-clone-05-client-model.pdf
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV.pdf
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part VI.pdf
PDF
Creating a Whatsapp Clone - Part III - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part VII.pdf
PDF
Creating a Whatsapp Clone - Part XIII - Transcript.pdf
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-01-introduction.pdf
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-03-server.pdf
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-02-server.pdf
create-netflix-clone-05-client-model.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part III - Transcript.pdf
Creating a Whatsapp Clone - Part VII.pdf
Creating a Whatsapp Clone - Part XIII - Transcript.pdf

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Chapter 3 Spatial Domain Image Processing.pdf

Creating a Whatsapp Clone - Part X - Transcript.pdf

  • 1. Creating a WhatsApp Clone - Part X The final part discussing the client side code covers the NewMessageForm class
  • 2. public class NewMessageForm extends Form { public NewMessageForm() { super("Select Contact", BoxLayout.y()); Form current = getCurrentForm(); getToolbar().setBackCommand("", e -> current.showBack()); MultiButton newGroup = new MultiButton("New group"); MultiButton newContact = new MultiButton("New contact"); FontImage.setMaterialIcon(newGroup, FontImage.MATERIAL_GROUP_ADD, 3.5f); FontImage.setMaterialIcon(newContact, FontImage.MATERIAL_PERSON_ADD, 3.5f); add(newGroup); add(newContact); Server.fetchContacts(lst -> { for(ChatContact c : lst) { MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); NewMessageForm NewMessageForm is a form we see when we press the floating action button in the main form
  • 3. public class NewMessageForm extends Form { public NewMessageForm() { super("Select Contact", BoxLayout.y()); Form current = getCurrentForm(); getToolbar().setBackCommand("", e -> current.showBack()); MultiButton newGroup = new MultiButton("New group"); MultiButton newContact = new MultiButton("New contact"); FontImage.setMaterialIcon(newGroup, FontImage.MATERIAL_GROUP_ADD, 3.5f); FontImage.setMaterialIcon(newContact, FontImage.MATERIAL_PERSON_ADD, 3.5f); add(newGroup); add(newContact); Server.fetchContacts(lst -> { for(ChatContact c : lst) { MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); NewMessageForm This class is trivial by comparison to the previous class. It’s just a box layout Y form that lets us pick the contact we wish to chat with
  • 4. public NewMessageForm() { super("Select Contact", BoxLayout.y()); Form current = getCurrentForm(); getToolbar().setBackCommand("", e -> current.showBack()); MultiButton newGroup = new MultiButton("New group"); MultiButton newContact = new MultiButton("New contact"); FontImage.setMaterialIcon(newGroup, FontImage.MATERIAL_GROUP_ADD, 3.5f); FontImage.setMaterialIcon(newContact, FontImage.MATERIAL_PERSON_ADD, 3.5f); add(newGroup); add(newContact); Server.fetchContacts(lst -> { for(ChatContact c : lst) { MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( NewMessageForm The new group and contact buttons aren’t currently mapped to anything. They are just simple buttons.
  • 5. FontImage.MATERIAL_GROUP_ADD, 3.5f); FontImage.setMaterialIcon(newContact, FontImage.MATERIAL_PERSON_ADD, 3.5f); add(newGroup); add(newContact); Server.fetchContacts(lst -> { for(ChatContact c : lst) { MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); NewMessageForm We use the fetch contacts method to fetch the list of contacts to show here
  • 6. add(newGroup); add(newContact); Server.fetchContacts(lst -> { for(ChatContact c : lst) { MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); NewMessageForm For every contact in the list of contacts we create a multi button matching the name and icon.
  • 7. MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); NewMessageForm If a contact is clicked we check if he has an ID. If not this is someone that might not be in the app yet. So we need to contact the server and check.
  • 8. MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); NewMessageForm findRegisteredUser finds the specific user based on his phone number
  • 9. MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); NewMessageForm If we get null as a result it means there is no such registered user in the app. We go back to the previous form and show a toastbar message there
  • 10. MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); NewMessageForm If there is we update the user id and save
  • 11. MultiButton mb = new MultiButton(c.name.get()); mb.setTextLine2(c.tagline.get()); mb.setIcon(c.getSmallIcon()); c.photo.addChangeListener(p -> mb.setIcon(c.getSmallIcon())); mb.addActionListener(e -> { if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); NewMessageForm We can then launch the chat form with this new contact
  • 12. if(c.id.get() == null) { Server.findRegisteredUser( c.phone.get(), contact -> { if(contact == null) { current.showBack(); callSerially(() -> ToastBar.showErrorMessage( "Contact isn't registered")); return; } c.id.set(contact.id.get()); Server.saveContacts(); }); return; } new ChatForm(c, current).show(); }); add(mb); } revalidate(); }); } } NewMessageForm Since all the multibuttons are added asynchronously we need to revalidate so they will show on the form. As I said this is a super simple short class and with that we finished the client side work…