SlideShare a Scribd company logo
Creating a Facebook Clone - Part XLI
public class NewPostForm extends Form {
private static final String[] POST_STYLES = {
"Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack",
"PostStyleRed", "PostStylePurple" };
private TextArea post = new TextArea(3, 80);
private String postStyleValue;
private String attachment;
private String mime;
private Button postButton;
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
NewPostForm
public class NewPostForm extends Form {
private static final String[] POST_STYLES = {
"Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack",
"PostStyleRed", "PostStylePurple" };
private TextArea post = new TextArea(3, 80);
private String postStyleValue;
private String attachment;
private String mime;
private Button postButton;
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
NewPostForm
public class NewPostForm extends Form {
private static final String[] POST_STYLES = {
"Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack",
"PostStyleRed", "PostStylePurple" };
private TextArea post = new TextArea(3, 80);
private String postStyleValue;
private String attachment;
private String mime;
private Button postButton;
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
NewPostForm
public class NewPostForm extends Form {
private static final String[] POST_STYLES = {
"Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack",
"PostStyleRed", "PostStylePurple" };
private TextArea post = new TextArea(3, 80);
private String postStyleValue;
private String attachment;
private String mime;
private Button postButton;
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
NewPostForm
BoxLayout.encloseY(
new Label(me.fullName(), "MultiLine1"),
FlowLayout.encloseIn(friends)));
add(NORTH, userSettings);
post.setUIID("Label");
post.setGrowByContent(false);
Component l;
if(postStyles != null) {
l = LayeredLayout.encloseIn(
BorderLayout.north(post), postStyles);
} else {
l = post;
}
add(CENTER, l);
setEditOnShow(post);
}
public static NewPostForm createPost() {
NewPostForm n = new NewPostForm();
Container postStyles = n.createPostStyles(n.post);
n.initUI(BorderLayout.south(postStyles));
return n;
}
NewPostForm
BoxLayout.encloseY(
new Label(me.fullName(), "MultiLine1"),
FlowLayout.encloseIn(friends)));
add(NORTH, userSettings);
post.setUIID("Label");
post.setGrowByContent(false);
Component l;
if(postStyles != null) {
l = LayeredLayout.encloseIn(
BorderLayout.north(post), postStyles);
} else {
l = post;
}
add(CENTER, l);
setEditOnShow(post);
}
public static NewPostForm createPost() {
NewPostForm n = new NewPostForm();
Container postStyles = n.createPostStyles(n.post);
n.initUI(BorderLayout.south(postStyles));
return n;
}
NewPostForm
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
postButton = getToolbar().findCommandComponent(c);
User me = ServerAPI.me();
Container userSettings = BorderLayout.west(
new Label(me.getAvatar(6.5f), "HalfPaddedContainer"));
Button friends = new Button("Friends", "FriendCombo");
FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE);
userSettings.add(CENTER,
BoxLayout.encloseY(
new Label(me.fullName(), "MultiLine1"),
FlowLayout.encloseIn(friends)));
add(NORTH, userSettings);
post.setUIID("Label");
NewPostForm
private NewPostForm() {
super("Create Post", new BorderLayout());
}
private void initUI(Container postStyles) {
Form current = getCurrentForm();
getToolbar().setBackCommand("Cancel",
Toolbar.BackCommandPolicy.
WHEN_USES_TITLE_OTHERWISE_ARROW,
e -> current.showBack());
Command c = getToolbar().addMaterialCommandToRightBar("",
FontImage.MATERIAL_DONE, e -> post(current));
postButton = getToolbar().findCommandComponent(c);
User me = ServerAPI.me();
Container userSettings = BorderLayout.west(
new Label(me.getAvatar(6.5f), "HalfPaddedContainer"));
Button friends = new Button("Friends", "FriendCombo");
FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE);
userSettings.add(CENTER,
BoxLayout.encloseY(
new Label(me.fullName(), "MultiLine1"),
FlowLayout.encloseIn(friends)));
add(NORTH, userSettings);
post.setUIID("Label");
NewPostForm
FontImage.MATERIAL_DONE, e -> post(current));
postButton = getToolbar().findCommandComponent(c);
User me = ServerAPI.me();
Container userSettings = BorderLayout.west(
new Label(me.getAvatar(6.5f), "HalfPaddedContainer"));
Button friends = new Button("Friends", "FriendCombo");
FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE);
userSettings.add(CENTER,
BoxLayout.encloseY(
new Label(me.fullName(), "MultiLine1"),
FlowLayout.encloseIn(friends)));
add(NORTH, userSettings);
post.setUIID("Label");
post.setGrowByContent(false);
Component l;
if(postStyles != null) {
l = LayeredLayout.encloseIn(
BorderLayout.north(post), postStyles);
} else {
l = post;
}
add(CENTER, l);
setEditOnShow(post);
}
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
n.initUI(BorderLayout.south(postStyles));
return n;
}
public static NewPostForm createImagePost(EncodedImage img,
ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
n.mime = "image/jpeg";
ScaleImageLabel i = new ScaleImageLabel(img) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
Slider s = n.upload(p);
n.add(SOUTH, LayeredLayout.encloseIn(
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
NewPostForm
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
private Slider upload(ImagePicker p) {
postButton.setEnabled(false);
Slider s = new Slider();
MultipartRequest m = p.upload(e -> {
attachment = e;
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
NewPostForm
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
private Slider upload(ImagePicker p) {
postButton.setEnabled(false);
Slider s = new Slider();
MultipartRequest m = p.upload(e -> {
attachment = e;
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
NewPostForm
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
private Slider upload(ImagePicker p) {
postButton.setEnabled(false);
Slider s = new Slider();
MultipartRequest m = p.upload(e -> {
attachment = e;
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
NewPostForm
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
private Slider upload(ImagePicker p) {
postButton.setEnabled(false);
Slider s = new Slider();
MultipartRequest m = p.upload(e -> {
attachment = e;
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
NewPostForm
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
private void post(Form previousForm) {
Dialog dlg = new InfiniteProgress().showInifiniteBlocking();
Post p = new Post().
content.set(post.getText()).
visibility.set("public").
styling.set(postStyleValue);
if(attachment != null) {
p.attachments.put(attachment, mime);
}
if(!ServerAPI.post(p)) {
dlg.dispose();
ToastBar.showErrorMessage("Error posting to server");
return;
}
previousForm.showBack();
}
private Container createPostStyles(TextArea post) {
NewPostForm
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
private void post(Form previousForm) {
Dialog dlg = new InfiniteProgress().showInifiniteBlocking();
Post p = new Post().
content.set(post.getText()).
visibility.set("public").
styling.set(postStyleValue);
if(attachment != null) {
p.attachments.put(attachment, mime);
}
if(!ServerAPI.post(p)) {
dlg.dispose();
ToastBar.showErrorMessage("Error posting to server");
return;
}
previousForm.showBack();
}
private Container createPostStyles(TextArea post) {
NewPostForm
postButton.setEnabled(true);
});
SliderBridge.bindProgress(m, s);
return s;
}
private void post(Form previousForm) {
Dialog dlg = new InfiniteProgress().showInifiniteBlocking();
Post p = new Post().
content.set(post.getText()).
visibility.set("public").
styling.set(postStyleValue);
if(attachment != null) {
p.attachments.put(attachment, mime);
}
if(!ServerAPI.post(p)) {
dlg.dispose();
ToastBar.showErrorMessage("Error posting to server");
return;
}
previousForm.showBack();
}
private Container createPostStyles(TextArea post) {
NewPostForm
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
Slider s = n.upload(p);
n.mime = "video/mp4";
Container videoContainer = new Container(new LayeredLayout()) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
NewPostForm
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
Slider s = n.upload(p);
n.mime = "video/mp4";
Container videoContainer = new Container(new LayeredLayout()) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
NewPostForm
i, BorderLayout.south(s)));
return n;
}
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
Slider s = n.upload(p);
n.mime = "video/mp4";
Container videoContainer = new Container(new LayeredLayout()) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
NewPostForm
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
Slider s = n.upload(p);
n.mime = "video/mp4";
Container videoContainer = new Container(new LayeredLayout()) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
NewPostForm
public static NewPostForm createVideoPost(Media m, ImagePicker p) {
NewPostForm n = new NewPostForm();
n.initUI(null);
Slider s = n.upload(p);
n.mime = "video/mp4";
Container videoContainer = new Container(new LayeredLayout()) {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(getDisplayWidth(),
getDisplayHeight() / 2);
}
};
videoContainer.add(m.getVideoComponent());
videoContainer.add(BorderLayout.south(s));
n.add(SOUTH, videoContainer);
n.addShowListener(e -> {
m.play();
m.setVolume(0);
m.setTime(Math.min(m.getDuration() / 2, 1000));
m.pause();
});
return n;
}
NewPostForm

More Related Content

PDF
Creating a Facebook Clone - Part XLI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XVI.pdf
PDF
Creating a Facebook Clone - Part XLII.pdf
PDF
Creating a Facebook Clone - Part XVI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIX - Transcript.pdf
PDF
Initial UI Mockup - Part 3.pdf
PDF
Creating an Uber Clone - Part V.pdf
PDF
Creating a Facebook Clone - Part XLII - Transcript.pdf
Creating a Facebook Clone - Part XLI - Transcript.pdf
Creating a Facebook Clone - Part XVI.pdf
Creating a Facebook Clone - Part XLII.pdf
Creating a Facebook Clone - Part XVI - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Initial UI Mockup - Part 3.pdf
Creating an Uber Clone - Part V.pdf
Creating a Facebook Clone - Part XLII - Transcript.pdf

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

PDF
Creating a Facebook Clone - Part VI - Transcript.pdf
PDF
Creating a Facebook Clone - Part VII.pdf
PDF
Creating a Facebook Clone - Part XLIII.pdf
PDF
Creating a Facebook Clone - Part VI.pdf
PDF
Creating a Facebook Clone - Part XXXV.pdf
PDF
Creating a Facebook Clone - Part XXXVI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XI.pdf
PDF
Initial UI Mockup - Part 2.pdf
PDF
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
PDF
Creating a Facebook Clone - Part XXXVI.pdf
PDF
Creating a Facebook Clone - Part XII.pdf
PDF
Creating a Facebook Clone - Part XXVIII.pdf
PDF
Creating an Uber Clone - Part XXXIX.pdf
PDF
Creating an Uber Clone - Part XXXX.pdf
PDF
Creating a Facebook Clone - Part XLVI.pdf
PDF
Initial UI Mockup - Part 3 - Transcript.pdf
PDF
Creating a Facebook Clone - Part XLVI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXXV - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
PDF
Creating an Uber Clone - Part IX.pdf
Creating a Facebook Clone - Part VI - Transcript.pdf
Creating a Facebook Clone - Part VII.pdf
Creating a Facebook Clone - Part XLIII.pdf
Creating a Facebook Clone - Part VI.pdf
Creating a Facebook Clone - Part XXXV.pdf
Creating a Facebook Clone - Part XXXVI - Transcript.pdf
Creating a Facebook Clone - Part XI.pdf
Initial UI Mockup - Part 2.pdf
2. Section 2. Implementing functionality in the PersonEntry. (1.5 ma.pdf
Creating a Facebook Clone - Part XXXVI.pdf
Creating a Facebook Clone - Part XII.pdf
Creating a Facebook Clone - Part XXVIII.pdf
Creating an Uber Clone - Part XXXIX.pdf
Creating an Uber Clone - Part XXXX.pdf
Creating a Facebook Clone - Part XLVI.pdf
Initial UI Mockup - Part 3 - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XXXV - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Creating an Uber Clone - Part IX.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 II.pdf
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part V - Transcript.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
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 II.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation theory and applications.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Empathic Computing: Creating Shared Understanding
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
sap open course for s4hana steps from ECC to s4
Encapsulation theory and applications.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Network Security Unit 5.pdf for BCA BBA.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Empathic Computing: Creating Shared Understanding

Creating a Facebook Clone - Part XLI.pdf

  • 1. Creating a Facebook Clone - Part XLI
  • 2. public class NewPostForm extends Form { private static final String[] POST_STYLES = { "Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack", "PostStyleRed", "PostStylePurple" }; private TextArea post = new TextArea(3, 80); private String postStyleValue; private String attachment; private String mime; private Button postButton; private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); NewPostForm
  • 3. public class NewPostForm extends Form { private static final String[] POST_STYLES = { "Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack", "PostStyleRed", "PostStylePurple" }; private TextArea post = new TextArea(3, 80); private String postStyleValue; private String attachment; private String mime; private Button postButton; private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); NewPostForm
  • 4. public class NewPostForm extends Form { private static final String[] POST_STYLES = { "Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack", "PostStyleRed", "PostStylePurple" }; private TextArea post = new TextArea(3, 80); private String postStyleValue; private String attachment; private String mime; private Button postButton; private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); NewPostForm
  • 5. public class NewPostForm extends Form { private static final String[] POST_STYLES = { "Label", "PostStyleHearts", "PostStyleHands", "PostStyleBlack", "PostStyleRed", "PostStylePurple" }; private TextArea post = new TextArea(3, 80); private String postStyleValue; private String attachment; private String mime; private Button postButton; private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); NewPostForm
  • 6. BoxLayout.encloseY( new Label(me.fullName(), "MultiLine1"), FlowLayout.encloseIn(friends))); add(NORTH, userSettings); post.setUIID("Label"); post.setGrowByContent(false); Component l; if(postStyles != null) { l = LayeredLayout.encloseIn( BorderLayout.north(post), postStyles); } else { l = post; } add(CENTER, l); setEditOnShow(post); } public static NewPostForm createPost() { NewPostForm n = new NewPostForm(); Container postStyles = n.createPostStyles(n.post); n.initUI(BorderLayout.south(postStyles)); return n; } NewPostForm
  • 7. BoxLayout.encloseY( new Label(me.fullName(), "MultiLine1"), FlowLayout.encloseIn(friends))); add(NORTH, userSettings); post.setUIID("Label"); post.setGrowByContent(false); Component l; if(postStyles != null) { l = LayeredLayout.encloseIn( BorderLayout.north(post), postStyles); } else { l = post; } add(CENTER, l); setEditOnShow(post); } public static NewPostForm createPost() { NewPostForm n = new NewPostForm(); Container postStyles = n.createPostStyles(n.post); n.initUI(BorderLayout.south(postStyles)); return n; } NewPostForm
  • 8. private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); postButton = getToolbar().findCommandComponent(c); User me = ServerAPI.me(); Container userSettings = BorderLayout.west( new Label(me.getAvatar(6.5f), "HalfPaddedContainer")); Button friends = new Button("Friends", "FriendCombo"); FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE); userSettings.add(CENTER, BoxLayout.encloseY( new Label(me.fullName(), "MultiLine1"), FlowLayout.encloseIn(friends))); add(NORTH, userSettings); post.setUIID("Label"); NewPostForm
  • 9. private NewPostForm() { super("Create Post", new BorderLayout()); } private void initUI(Container postStyles) { Form current = getCurrentForm(); getToolbar().setBackCommand("Cancel", Toolbar.BackCommandPolicy. WHEN_USES_TITLE_OTHERWISE_ARROW, e -> current.showBack()); Command c = getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_DONE, e -> post(current)); postButton = getToolbar().findCommandComponent(c); User me = ServerAPI.me(); Container userSettings = BorderLayout.west( new Label(me.getAvatar(6.5f), "HalfPaddedContainer")); Button friends = new Button("Friends", "FriendCombo"); FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE); userSettings.add(CENTER, BoxLayout.encloseY( new Label(me.fullName(), "MultiLine1"), FlowLayout.encloseIn(friends))); add(NORTH, userSettings); post.setUIID("Label"); NewPostForm
  • 10. FontImage.MATERIAL_DONE, e -> post(current)); postButton = getToolbar().findCommandComponent(c); User me = ServerAPI.me(); Container userSettings = BorderLayout.west( new Label(me.getAvatar(6.5f), "HalfPaddedContainer")); Button friends = new Button("Friends", "FriendCombo"); FontImage.setMaterialIcon(friends, FontImage.MATERIAL_PEOPLE); userSettings.add(CENTER, BoxLayout.encloseY( new Label(me.fullName(), "MultiLine1"), FlowLayout.encloseIn(friends))); add(NORTH, userSettings); post.setUIID("Label"); post.setGrowByContent(false); Component l; if(postStyles != null) { l = LayeredLayout.encloseIn( BorderLayout.north(post), postStyles); } else { l = post; } add(CENTER, l); setEditOnShow(post); } NewPostForm
  • 11. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 12. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 13. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 14. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 15. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 16. n.initUI(BorderLayout.south(postStyles)); return n; } public static NewPostForm createImagePost(EncodedImage img, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); n.mime = "image/jpeg"; ScaleImageLabel i = new ScaleImageLabel(img) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; Slider s = n.upload(p); n.add(SOUTH, LayeredLayout.encloseIn( i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); NewPostForm
  • 17. } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } private Slider upload(ImagePicker p) { postButton.setEnabled(false); Slider s = new Slider(); MultipartRequest m = p.upload(e -> { attachment = e; postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } NewPostForm
  • 18. } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } private Slider upload(ImagePicker p) { postButton.setEnabled(false); Slider s = new Slider(); MultipartRequest m = p.upload(e -> { attachment = e; postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } NewPostForm
  • 19. } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } private Slider upload(ImagePicker p) { postButton.setEnabled(false); Slider s = new Slider(); MultipartRequest m = p.upload(e -> { attachment = e; postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } NewPostForm
  • 20. } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } private Slider upload(ImagePicker p) { postButton.setEnabled(false); Slider s = new Slider(); MultipartRequest m = p.upload(e -> { attachment = e; postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } NewPostForm
  • 21. postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } private void post(Form previousForm) { Dialog dlg = new InfiniteProgress().showInifiniteBlocking(); Post p = new Post(). content.set(post.getText()). visibility.set("public"). styling.set(postStyleValue); if(attachment != null) { p.attachments.put(attachment, mime); } if(!ServerAPI.post(p)) { dlg.dispose(); ToastBar.showErrorMessage("Error posting to server"); return; } previousForm.showBack(); } private Container createPostStyles(TextArea post) { NewPostForm
  • 22. postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } private void post(Form previousForm) { Dialog dlg = new InfiniteProgress().showInifiniteBlocking(); Post p = new Post(). content.set(post.getText()). visibility.set("public"). styling.set(postStyleValue); if(attachment != null) { p.attachments.put(attachment, mime); } if(!ServerAPI.post(p)) { dlg.dispose(); ToastBar.showErrorMessage("Error posting to server"); return; } previousForm.showBack(); } private Container createPostStyles(TextArea post) { NewPostForm
  • 23. postButton.setEnabled(true); }); SliderBridge.bindProgress(m, s); return s; } private void post(Form previousForm) { Dialog dlg = new InfiniteProgress().showInifiniteBlocking(); Post p = new Post(). content.set(post.getText()). visibility.set("public"). styling.set(postStyleValue); if(attachment != null) { p.attachments.put(attachment, mime); } if(!ServerAPI.post(p)) { dlg.dispose(); ToastBar.showErrorMessage("Error posting to server"); return; } previousForm.showBack(); } private Container createPostStyles(TextArea post) { NewPostForm
  • 24. i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); Slider s = n.upload(p); n.mime = "video/mp4"; Container videoContainer = new Container(new LayeredLayout()) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); NewPostForm
  • 25. i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); Slider s = n.upload(p); n.mime = "video/mp4"; Container videoContainer = new Container(new LayeredLayout()) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); NewPostForm
  • 26. i, BorderLayout.south(s))); return n; } public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); Slider s = n.upload(p); n.mime = "video/mp4"; Container videoContainer = new Container(new LayeredLayout()) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); NewPostForm
  • 27. public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); Slider s = n.upload(p); n.mime = "video/mp4"; Container videoContainer = new Container(new LayeredLayout()) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } NewPostForm
  • 28. public static NewPostForm createVideoPost(Media m, ImagePicker p) { NewPostForm n = new NewPostForm(); n.initUI(null); Slider s = n.upload(p); n.mime = "video/mp4"; Container videoContainer = new Container(new LayeredLayout()) { @Override protected Dimension calcPreferredSize() { return new Dimension(getDisplayWidth(), getDisplayHeight() / 2); } }; videoContainer.add(m.getVideoComponent()); videoContainer.add(BorderLayout.south(s)); n.add(SOUTH, videoContainer); n.addShowListener(e -> { m.play(); m.setVolume(0); m.setTime(Math.min(m.getDuration() / 2, 1000)); m.pause(); }); return n; } NewPostForm