SlideShare a Scribd company logo
1 of 20
Download to read offline
Creating a Facebook Clone - Part XXX
public class MainForm extends Form {
private Tabs mainUI = new Tabs();
public MainForm() {
super("", new BorderLayout());
mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer());
FloatingActionButton fab =
FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS);
Container friends = fab.bindFabToContainer(new FriendsContainer());
fab.addActionListener(e -> uploadContacts());
mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f,
friends);
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
MainForm
public class MainForm extends Form {
private Tabs mainUI = new Tabs();
public MainForm() {
super("", new BorderLayout());
mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer());
FloatingActionButton fab =
FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS);
Container friends = fab.bindFabToContainer(new FriendsContainer());
fab.addActionListener(e -> uploadContacts());
mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f,
friends);
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
MainForm
public class MainForm extends Form {
private Tabs mainUI = new Tabs();
public MainForm() {
super("", new BorderLayout());
mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer());
FloatingActionButton fab =
FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS);
Container friends = fab.bindFabToContainer(new FriendsContainer());
fab.addActionListener(e -> uploadContacts());
mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f,
friends);
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
MainForm
public class MainForm extends Form {
private Tabs mainUI = new Tabs();
public MainForm() {
super("", new BorderLayout());
mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer());
FloatingActionButton fab =
FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS);
Container friends = fab.bindFabToContainer(new FriendsContainer());
fab.addActionListener(e -> uploadContacts());
mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f,
friends);
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
MainForm
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
getToolbar().addMaterialCommandToRightBar("",
MATERIAL_CHAT, 4, e -> {});
Button searchButton = new Button("Search", "TitleSearch");
setMaterialIcon(searchButton, MATERIAL_SEARCH);
getToolbar().setTitleComponent(searchButton);
searchButton.addActionListener(e -> new SearchForm().show());
}
private void uploadContacts() {
startThread(() -> {
Contact[] cnt = Display.getInstance().
getAllContacts(true, true, false, true, true, false);
ServerAPI.uploadContacts(cnt);
}, "ContactUploader").start();
}
}
MainForm
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
getToolbar().addMaterialCommandToRightBar("",
MATERIAL_CHAT, 4, e -> {});
Button searchButton = new Button("Search", "TitleSearch");
setMaterialIcon(searchButton, MATERIAL_SEARCH);
getToolbar().setTitleComponent(searchButton);
searchButton.addActionListener(e -> new SearchForm().show());
}
private void uploadContacts() {
startThread(() -> {
Contact[] cnt = Display.getInstance().
getAllContacts(true, true, false, true, true, false);
ServerAPI.uploadContacts(cnt);
}, "ContactUploader").start();
}
}
MainForm
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
getToolbar().addMaterialCommandToRightBar("",
MATERIAL_CHAT, 4, e -> {});
Button searchButton = new Button("Search", "TitleSearch");
setMaterialIcon(searchButton, MATERIAL_SEARCH);
getToolbar().setTitleComponent(searchButton);
searchButton.addActionListener(e -> new SearchForm().show());
}
private void uploadContacts() {
startThread(() -> {
Contact[] cnt = Display.getInstance().
getAllContacts(true, true, false, true, true, false);
ServerAPI.uploadContacts(cnt);
}, "ContactUploader").start();
}
}
MainForm
mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE,
5f, new NotificationsContainer());
mainUI.addTab("", MATERIAL_MENU, 5f,
new MoreContainer());
add(CENTER, mainUI);
getToolbar().addMaterialCommandToLeftBar("",
MATERIAL_CAMERA_ALT, 4, e -> {});
getToolbar().addMaterialCommandToRightBar("",
MATERIAL_CHAT, 4, e -> {});
Button searchButton = new Button("Search", "TitleSearch");
setMaterialIcon(searchButton, MATERIAL_SEARCH);
getToolbar().setTitleComponent(searchButton);
searchButton.addActionListener(e -> new SearchForm().show());
}
private void uploadContacts() {
startThread(() -> {
Contact[] cnt = Display.getInstance().
getAllContacts(true, true, false, true, true, false);
ServerAPI.uploadContacts(cnt);
}, "ContactUploader").start();
}
}
MainForm
padding: 1.5mm;
text-align: center;
font-family: "native:MainRegular";
font-size: 3.5mm;
}
SmallLabel {
font-family: "native:MainLight";
font-size: 2mm;
}
FloatingActionButton {
background: #587EBE;
padding: 1.5mm;
text-align: center;
}
Comment {
color: black;
font-family: "native:MainThin";
font-size: 2.6mm;
border: cn1-pill-border;
background-color: #dbdbdb;
padding: 1mm 3mm 1mm 3mm;
theme.css
add(UIUtils.createHalfSpace());
}
}
private Container friendRequestEntry(User u, Image avatar,
boolean request) {
Label name = new Label(u.fullName(), "FriendName");
Button confirm;
Button delete;
if(request) {
confirm = new Button("Confirm", "FriendConfirm");
delete = new Button("Delete", "FriendDelete");
bindConfirmDeleteEvent(u, confirm, delete);
} else {
confirm = new Button("Add Friend", "FriendConfirm");
delete = new Button("Remove", "FriendDelete");
bindAddRemoveFriendEvent(u, confirm, delete);
}
Container cnt =
BoxLayout.encloseY(name,
GridLayout.encloseIn(2, confirm, delete));
cnt.setUIID("PaddedContainer");
return BorderLayout.centerEastWest(cnt, null,
new Label(avatar, "Container"));
FriendsContainer
confirm = new Button("Add Friend", "FriendConfirm");
delete = new Button("Remove", "FriendDelete");
bindAddRemoveFriendEvent(u, confirm, delete);
}
Container cnt =
BoxLayout.encloseY(name,
GridLayout.encloseIn(2, confirm, delete));
cnt.setUIID("PaddedContainer");
return BorderLayout.centerEastWest(cnt, null,
new Label(avatar, "Container"));
}
private Container findParent(Container button) {
if(button.getParent() != this) {
return findParent(button.getParent());
}
return button;
}
private void bindAddRemoveFriendEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
ServerAPI.sendFriendRequest(u.id.get());
findParent(remove.getParent()).remove();
FriendsContainer
if(button.getParent() != this) {
return findParent(button.getParent());
}
return button;
}
private void bindAddRemoveFriendEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
ServerAPI.sendFriendRequest(u.id.get());
findParent(remove.getParent()).remove();
animateLayout(150);
ToastBar.showMessage("Sent friend request",
FontImage.MATERIAL_INFO);
ServerAPI.refreshMe();
});
remove.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
ServerAPI.me().peopleYouMayKnow.remove(u);
ServerAPI.update(ServerAPI.me());
});
}
FriendsContainer
if(button.getParent() != this) {
return findParent(button.getParent());
}
return button;
}
private void bindAddRemoveFriendEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
ServerAPI.sendFriendRequest(u.id.get());
findParent(remove.getParent()).remove();
animateLayout(150);
ToastBar.showMessage("Sent friend request",
FontImage.MATERIAL_INFO);
ServerAPI.refreshMe();
});
remove.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
ServerAPI.me().peopleYouMayKnow.remove(u);
ServerAPI.update(ServerAPI.me());
});
}
FriendsContainer
if(button.getParent() != this) {
return findParent(button.getParent());
}
return button;
}
private void bindAddRemoveFriendEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
ServerAPI.sendFriendRequest(u.id.get());
findParent(remove.getParent()).remove();
animateLayout(150);
ToastBar.showMessage("Sent friend request",
FontImage.MATERIAL_INFO);
ServerAPI.refreshMe();
});
remove.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
ServerAPI.me().peopleYouMayKnow.remove(u);
ServerAPI.update(ServerAPI.me());
});
}
FriendsContainer
if(button.getParent() != this) {
return findParent(button.getParent());
}
return button;
}
private void bindAddRemoveFriendEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
ServerAPI.sendFriendRequest(u.id.get());
findParent(remove.getParent()).remove();
animateLayout(150);
ToastBar.showMessage("Sent friend request",
FontImage.MATERIAL_INFO);
ServerAPI.refreshMe();
});
remove.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
ServerAPI.me().peopleYouMayKnow.remove(u);
ServerAPI.update(ServerAPI.me());
});
}
FriendsContainer
ServerAPI.update(ServerAPI.me());
});
}
private void bindConfirmDeleteEvent(
User u, Button add, Button remove) {
add.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
if(ServerAPI.acceptFriendRequest(u.id.get())) {
ServerAPI.refreshMe();
ToastBar.showMessage("You are now friends with " +
u.fullName(),
FontImage.MATERIAL_INFO);
}
});
remove.addActionListener(e -> {
findParent(remove.getParent()).remove();
animateLayout(150);
ServerAPI.me().friendRequests.remove(u);
ServerAPI.update(ServerAPI.me());
});
}
FriendsContainer
public class NotificationsContainer extends InfiniteContainer {
@Override
public Component[] fetchComponents(int index, int amount) {
int page = index / amount;
if(index % amount > 0) {
page++;
}
List<Notification> response = ServerAPI.listNotifications(page,
amount);
if(response == null) {
return null;
}
Component[] notifications = new Component[response.size()];
int iter = 0;
for(Notification n : response) {
notifications[iter] = createNotificationEntry(n);
iter++;
}
return notifications;
}
NotificationContainer
public class NotificationsContainer extends InfiniteContainer {
@Override
public Component[] fetchComponents(int index, int amount) {
int page = index / amount;
if(index % amount > 0) {
page++;
}
List<Notification> response = ServerAPI.listNotifications(page,
amount);
if(response == null) {
return null;
}
Component[] notifications = new Component[response.size()];
int iter = 0;
for(Notification n : response) {
notifications[iter] = createNotificationEntry(n);
iter++;
}
return notifications;
}
NotificationContainer
public class NotificationsContainer extends InfiniteContainer {
@Override
public Component[] fetchComponents(int index, int amount) {
int page = index / amount;
if(index % amount > 0) {
page++;
}
List<Notification> response = ServerAPI.listNotifications(page,
amount);
if(response == null) {
return null;
}
Component[] notifications = new Component[response.size()];
int iter = 0;
for(Notification n : response) {
notifications[iter] = createNotificationEntry(n);
iter++;
}
return notifications;
}
NotificationContainer

More Related Content

Similar to Creating a Facebook Clone - Part XXX.pdf

Similar to Creating a Facebook Clone - Part XXX.pdf (20)

Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdfCreating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part VI.pdf
 
Creating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdfCreating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdf
 
Initial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdfInitial UI Mockup - Part 3.pdf
Initial UI Mockup - Part 3.pdf
 
Creating a Facebook Clone - Part XII.pdf
Creating a Facebook Clone - Part XII.pdfCreating a Facebook Clone - Part XII.pdf
Creating a Facebook Clone - Part XII.pdf
 
Creating a Facebook Clone - Part XLII.pdf
Creating a Facebook Clone - Part XLII.pdfCreating a Facebook Clone - Part XLII.pdf
Creating a Facebook Clone - Part XLII.pdf
 
Creating a Facebook Clone - Part XV - Transcript.pdf
Creating a Facebook Clone - Part XV - Transcript.pdfCreating a Facebook Clone - Part XV - Transcript.pdf
Creating a Facebook Clone - Part XV - Transcript.pdf
 
Initial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdfInitial UI Mockup - Part 2 - Transcript.pdf
Initial UI Mockup - Part 2 - Transcript.pdf
 
Initial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdfInitial UI Mockup - Part 2.pdf
Initial UI Mockup - Part 2.pdf
 
Creating a Facebook Clone - Part XLI.pdf
Creating a Facebook Clone - Part XLI.pdfCreating a Facebook Clone - Part XLI.pdf
Creating a Facebook Clone - Part XLI.pdf
 
Oop lecture9 10
Oop lecture9 10Oop lecture9 10
Oop lecture9 10
 
Creating a Whatsapp Clone - Part X.pdf
Creating a Whatsapp Clone - Part X.pdfCreating a Whatsapp Clone - Part X.pdf
Creating a Whatsapp Clone - Part X.pdf
 
Program klik sederhana
Program klik sederhanaProgram klik sederhana
Program klik sederhana
 
Creating a Facebook Clone - Part IV.pdf
Creating a Facebook Clone - Part IV.pdfCreating a Facebook Clone - Part IV.pdf
Creating a Facebook Clone - Part IV.pdf
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Creating a Whatsapp Clone - Part X - Transcript.pdf
Creating a Whatsapp Clone - Part X - Transcript.pdfCreating a Whatsapp Clone - Part X - Transcript.pdf
Creating a Whatsapp Clone - Part X - Transcript.pdf
 
Creating a Facebook Clone - Part XXXIII - Transcript.pdf
Creating a Facebook Clone - Part XXXIII - Transcript.pdfCreating a Facebook Clone - Part XXXIII - Transcript.pdf
Creating a Facebook Clone - Part XXXIII - Transcript.pdf
 
Creating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdfCreating a Facebook Clone - Part XXVIII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
 
Extracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdfExtracting ui Design - part 6 - transcript.pdf
Extracting ui Design - part 6 - transcript.pdf
 
07 intent
07 intent07 intent
07 intent
 
Creating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdfCreating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdf
 

More from ShaiAlmog1

More from ShaiAlmog1 (20)

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

Recently uploaded

Recently uploaded (20)

Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 

Creating a Facebook Clone - Part XXX.pdf

  • 1. Creating a Facebook Clone - Part XXX
  • 2. public class MainForm extends Form { private Tabs mainUI = new Tabs(); public MainForm() { super("", new BorderLayout()); mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer()); FloatingActionButton fab = FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS); Container friends = fab.bindFabToContainer(new FriendsContainer()); fab.addActionListener(e -> uploadContacts()); mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f, friends); mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); MainForm
  • 3. public class MainForm extends Form { private Tabs mainUI = new Tabs(); public MainForm() { super("", new BorderLayout()); mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer()); FloatingActionButton fab = FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS); Container friends = fab.bindFabToContainer(new FriendsContainer()); fab.addActionListener(e -> uploadContacts()); mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f, friends); mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); MainForm
  • 4. public class MainForm extends Form { private Tabs mainUI = new Tabs(); public MainForm() { super("", new BorderLayout()); mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer()); FloatingActionButton fab = FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS); Container friends = fab.bindFabToContainer(new FriendsContainer()); fab.addActionListener(e -> uploadContacts()); mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f, friends); mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); MainForm
  • 5. public class MainForm extends Form { private Tabs mainUI = new Tabs(); public MainForm() { super("", new BorderLayout()); mainUI.addTab("", MATERIAL_WEB, 5f, new NewsfeedContainer()); FloatingActionButton fab = FloatingActionButton.createFAB(MATERIAL_IMPORT_CONTACTS); Container friends = fab.bindFabToContainer(new FriendsContainer()); fab.addActionListener(e -> uploadContacts()); mainUI.addTab("", MATERIAL_PEOPLE_OUTLINE, 5f, friends); mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); MainForm
  • 6. mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); getToolbar().addMaterialCommandToRightBar("", MATERIAL_CHAT, 4, e -> {}); Button searchButton = new Button("Search", "TitleSearch"); setMaterialIcon(searchButton, MATERIAL_SEARCH); getToolbar().setTitleComponent(searchButton); searchButton.addActionListener(e -> new SearchForm().show()); } private void uploadContacts() { startThread(() -> { Contact[] cnt = Display.getInstance(). getAllContacts(true, true, false, true, true, false); ServerAPI.uploadContacts(cnt); }, "ContactUploader").start(); } } MainForm
  • 7. mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); getToolbar().addMaterialCommandToRightBar("", MATERIAL_CHAT, 4, e -> {}); Button searchButton = new Button("Search", "TitleSearch"); setMaterialIcon(searchButton, MATERIAL_SEARCH); getToolbar().setTitleComponent(searchButton); searchButton.addActionListener(e -> new SearchForm().show()); } private void uploadContacts() { startThread(() -> { Contact[] cnt = Display.getInstance(). getAllContacts(true, true, false, true, true, false); ServerAPI.uploadContacts(cnt); }, "ContactUploader").start(); } } MainForm
  • 8. mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); getToolbar().addMaterialCommandToRightBar("", MATERIAL_CHAT, 4, e -> {}); Button searchButton = new Button("Search", "TitleSearch"); setMaterialIcon(searchButton, MATERIAL_SEARCH); getToolbar().setTitleComponent(searchButton); searchButton.addActionListener(e -> new SearchForm().show()); } private void uploadContacts() { startThread(() -> { Contact[] cnt = Display.getInstance(). getAllContacts(true, true, false, true, true, false); ServerAPI.uploadContacts(cnt); }, "ContactUploader").start(); } } MainForm
  • 9. mainUI.addTab("", MATERIAL_NOTIFICATIONS_NONE, 5f, new NotificationsContainer()); mainUI.addTab("", MATERIAL_MENU, 5f, new MoreContainer()); add(CENTER, mainUI); getToolbar().addMaterialCommandToLeftBar("", MATERIAL_CAMERA_ALT, 4, e -> {}); getToolbar().addMaterialCommandToRightBar("", MATERIAL_CHAT, 4, e -> {}); Button searchButton = new Button("Search", "TitleSearch"); setMaterialIcon(searchButton, MATERIAL_SEARCH); getToolbar().setTitleComponent(searchButton); searchButton.addActionListener(e -> new SearchForm().show()); } private void uploadContacts() { startThread(() -> { Contact[] cnt = Display.getInstance(). getAllContacts(true, true, false, true, true, false); ServerAPI.uploadContacts(cnt); }, "ContactUploader").start(); } } MainForm
  • 10. padding: 1.5mm; text-align: center; font-family: "native:MainRegular"; font-size: 3.5mm; } SmallLabel { font-family: "native:MainLight"; font-size: 2mm; } FloatingActionButton { background: #587EBE; padding: 1.5mm; text-align: center; } Comment { color: black; font-family: "native:MainThin"; font-size: 2.6mm; border: cn1-pill-border; background-color: #dbdbdb; padding: 1mm 3mm 1mm 3mm; theme.css
  • 11. add(UIUtils.createHalfSpace()); } } private Container friendRequestEntry(User u, Image avatar, boolean request) { Label name = new Label(u.fullName(), "FriendName"); Button confirm; Button delete; if(request) { confirm = new Button("Confirm", "FriendConfirm"); delete = new Button("Delete", "FriendDelete"); bindConfirmDeleteEvent(u, confirm, delete); } else { confirm = new Button("Add Friend", "FriendConfirm"); delete = new Button("Remove", "FriendDelete"); bindAddRemoveFriendEvent(u, confirm, delete); } Container cnt = BoxLayout.encloseY(name, GridLayout.encloseIn(2, confirm, delete)); cnt.setUIID("PaddedContainer"); return BorderLayout.centerEastWest(cnt, null, new Label(avatar, "Container")); FriendsContainer
  • 12. confirm = new Button("Add Friend", "FriendConfirm"); delete = new Button("Remove", "FriendDelete"); bindAddRemoveFriendEvent(u, confirm, delete); } Container cnt = BoxLayout.encloseY(name, GridLayout.encloseIn(2, confirm, delete)); cnt.setUIID("PaddedContainer"); return BorderLayout.centerEastWest(cnt, null, new Label(avatar, "Container")); } private Container findParent(Container button) { if(button.getParent() != this) { return findParent(button.getParent()); } return button; } private void bindAddRemoveFriendEvent( User u, Button add, Button remove) { add.addActionListener(e -> { ServerAPI.sendFriendRequest(u.id.get()); findParent(remove.getParent()).remove(); FriendsContainer
  • 13. if(button.getParent() != this) { return findParent(button.getParent()); } return button; } private void bindAddRemoveFriendEvent( User u, Button add, Button remove) { add.addActionListener(e -> { ServerAPI.sendFriendRequest(u.id.get()); findParent(remove.getParent()).remove(); animateLayout(150); ToastBar.showMessage("Sent friend request", FontImage.MATERIAL_INFO); ServerAPI.refreshMe(); }); remove.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); ServerAPI.me().peopleYouMayKnow.remove(u); ServerAPI.update(ServerAPI.me()); }); } FriendsContainer
  • 14. if(button.getParent() != this) { return findParent(button.getParent()); } return button; } private void bindAddRemoveFriendEvent( User u, Button add, Button remove) { add.addActionListener(e -> { ServerAPI.sendFriendRequest(u.id.get()); findParent(remove.getParent()).remove(); animateLayout(150); ToastBar.showMessage("Sent friend request", FontImage.MATERIAL_INFO); ServerAPI.refreshMe(); }); remove.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); ServerAPI.me().peopleYouMayKnow.remove(u); ServerAPI.update(ServerAPI.me()); }); } FriendsContainer
  • 15. if(button.getParent() != this) { return findParent(button.getParent()); } return button; } private void bindAddRemoveFriendEvent( User u, Button add, Button remove) { add.addActionListener(e -> { ServerAPI.sendFriendRequest(u.id.get()); findParent(remove.getParent()).remove(); animateLayout(150); ToastBar.showMessage("Sent friend request", FontImage.MATERIAL_INFO); ServerAPI.refreshMe(); }); remove.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); ServerAPI.me().peopleYouMayKnow.remove(u); ServerAPI.update(ServerAPI.me()); }); } FriendsContainer
  • 16. if(button.getParent() != this) { return findParent(button.getParent()); } return button; } private void bindAddRemoveFriendEvent( User u, Button add, Button remove) { add.addActionListener(e -> { ServerAPI.sendFriendRequest(u.id.get()); findParent(remove.getParent()).remove(); animateLayout(150); ToastBar.showMessage("Sent friend request", FontImage.MATERIAL_INFO); ServerAPI.refreshMe(); }); remove.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); ServerAPI.me().peopleYouMayKnow.remove(u); ServerAPI.update(ServerAPI.me()); }); } FriendsContainer
  • 17. ServerAPI.update(ServerAPI.me()); }); } private void bindConfirmDeleteEvent( User u, Button add, Button remove) { add.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); if(ServerAPI.acceptFriendRequest(u.id.get())) { ServerAPI.refreshMe(); ToastBar.showMessage("You are now friends with " + u.fullName(), FontImage.MATERIAL_INFO); } }); remove.addActionListener(e -> { findParent(remove.getParent()).remove(); animateLayout(150); ServerAPI.me().friendRequests.remove(u); ServerAPI.update(ServerAPI.me()); }); } FriendsContainer
  • 18. public class NotificationsContainer extends InfiniteContainer { @Override public Component[] fetchComponents(int index, int amount) { int page = index / amount; if(index % amount > 0) { page++; } List<Notification> response = ServerAPI.listNotifications(page, amount); if(response == null) { return null; } Component[] notifications = new Component[response.size()]; int iter = 0; for(Notification n : response) { notifications[iter] = createNotificationEntry(n); iter++; } return notifications; } NotificationContainer
  • 19. public class NotificationsContainer extends InfiniteContainer { @Override public Component[] fetchComponents(int index, int amount) { int page = index / amount; if(index % amount > 0) { page++; } List<Notification> response = ServerAPI.listNotifications(page, amount); if(response == null) { return null; } Component[] notifications = new Component[response.size()]; int iter = 0; for(Notification n : response) { notifications[iter] = createNotificationEntry(n); iter++; } return notifications; } NotificationContainer
  • 20. public class NotificationsContainer extends InfiniteContainer { @Override public Component[] fetchComponents(int index, int amount) { int page = index / amount; if(index % amount > 0) { page++; } List<Notification> response = ServerAPI.listNotifications(page, amount); if(response == null) { return null; } Component[] notifications = new Component[response.size()]; int iter = 0; for(Notification n : response) { notifications[iter] = createNotificationEntry(n); iter++; } return notifications; } NotificationContainer