SlideShare a Scribd company logo
Creating a Facebook Clone - Part XL
public class Post implements PropertyBusinessObject {
public final Property<String, Post> id = new Property<>("id");
public final Property<User, Post> user = new Property<>("user",
User.class);
public final LongProperty<Post> date = new LongProperty<>("date");
public final Property<String, Post> title = new Property<>("title");
public final Property<String, Post> content = new Property<>("content");
public final Property<String, Post> visibility =
new Property<>("visibility");
public final Property<String, Post> styling = new Property<>("styling");
public final ListProperty<Comment, Post> comments =
new ListProperty<>("comments", Comment.class);
public final ListProperty<User, Post> likes =
new ListProperty<>("likes", User.class);
public final MapProperty<String, String, Post> attachments =
new MapProperty<>("attachments", String.class, String.class);
private final PropertyIndex idx = new PropertyIndex(this, "Post",
id, user, date, title, content, visibility, styling, comments,
likes, attachments);
Post
public class Post implements PropertyBusinessObject {
public final Property<String, Post> id = new Property<>("id");
public final Property<User, Post> user = new Property<>("user",
User.class);
public final LongProperty<Post> date = new LongProperty<>("date");
public final Property<String, Post> title = new Property<>("title");
public final Property<String, Post> content = new Property<>("content");
public final Property<String, Post> visibility =
new Property<>("visibility");
public final Property<String, Post> styling = new Property<>("styling");
public final ListProperty<Comment, Post> comments =
new ListProperty<>("comments", Comment.class);
public final ListProperty<User, Post> likes =
new ListProperty<>("likes", User.class);
public final MapProperty<String, String, Post> attachments =
new MapProperty<>("attachments", String.class, String.class);
private final PropertyIndex idx = new PropertyIndex(this, "Post",
id, user, date, title, content, visibility, styling, comments,
likes, attachments);
Post
Response<String> s = post("user/contacts").
body(contactsToJSON(contacts)).getAsString();
return "OK".equals(s.getResponseData());
}
public static MultipartRequest uploadMedia(String mime, String role,
String visibility, String fileName, byte[] data,
SuccessCallback<String> callback) {
MultipartRequest mp = new MultipartRequest() {
private String mediaId;
@Override
protected void readResponse(InputStream input)
throws IOException {
mediaId = Util.readToString(input);
}
@Override
protected void postResponse() {
callback.onSucess(mediaId);
}
};
mp.setUrl(BASE_URL + "media/upload");
mp.addRequestHeader("auth", token);
ServerAPI
Response<String> s = post("user/contacts").
body(contactsToJSON(contacts)).getAsString();
return "OK".equals(s.getResponseData());
}
public static MultipartRequest uploadMedia(String mime, String role,
String visibility, String fileName, byte[] data,
SuccessCallback<String> callback) {
MultipartRequest mp = new MultipartRequest() {
private String mediaId;
@Override
protected void readResponse(InputStream input)
throws IOException {
mediaId = Util.readToString(input);
}
@Override
protected void postResponse() {
callback.onSucess(mediaId);
}
};
mp.setUrl(BASE_URL + "media/upload");
mp.addRequestHeader("auth", token);
ServerAPI
@Override
protected void postResponse() {
callback.onSucess(mediaId);
}
};
mp.setUrl(BASE_URL + "media/upload");
mp.addRequestHeader("auth", token);
mp.addRequestHeader("Accept", "application/json");
mp.addArgument("role", role);
mp.addArgument("visibility", visibility);
if(data == null) {
try {
mp.addData("file", fileName, mime);
} catch(IOException err) {
Log.e(err);
throw new RuntimeException(err);
}
} else {
mp.addData("file", data, mime);
}
mp.setFilename("file", fileName);
addToQueue(mp);
return mp;
ServerAPI

More Related Content

PDF
Creating a Facebook Clone - Part XIV.pdf
PDF
Creating a Facebook Clone - Part X.pdf
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV.pdf
PDF
Creating a Facebook Clone - Part XIV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part III.pdf
PDF
Creating a Facebook Clone - Part XL - Transcript.pdf
PDF
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XIV.pdf
Creating a Facebook Clone - Part X.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Facebook Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part III.pdf
Creating a Facebook Clone - Part XL - Transcript.pdf
Creating a Facebook Clone - Part XI.pdf

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

PDF
create-netflix-clone-05-client-model.pdf
PDF
Creating a Facebook Clone - Part XXXVIII.pdf
PDF
Creating a Facebook Clone - Part XIX - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIV.pdf
PDF
Creating a Facebook Clone - Part XIX.pdf
PDF
Creating a Whatsapp Clone - Part III - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXXI - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIII.pdf
PDF
Dev Day Andreas Roth.pdf
PDF
Creating an Uber Clone - Part XXXX.pdf
PDF
Creating a Facebook Clone - Part XXXI.pdf
PDF
Creating a Facebook Clone - Part XXIV - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
DOCX
Week 12 code
PDF
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
PDF
Creating a Facebook Clone - Part XX.pdf
PDF
Ext GWT 3.0 Data Widgets
PDF
Creating a Facebook Clone - Part XII.pdf
PDF
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXXIII.pdf
create-netflix-clone-05-client-model.pdf
Creating a Facebook Clone - Part XXXVIII.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XIX.pdf
Creating a Whatsapp Clone - Part III - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXIII.pdf
Dev Day Andreas Roth.pdf
Creating an Uber Clone - Part XXXX.pdf
Creating a Facebook Clone - Part XXXI.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXVIII - Transcript.pdf
Week 12 code
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
Creating a Facebook Clone - Part XX.pdf
Ext GWT 3.0 Data Widgets
Creating a Facebook Clone - Part XII.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXIII.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
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 I - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IX.pdf
PDF
Creating a Whatsapp Clone - Part VI.pdf
PDF
Creating a Whatsapp Clone - Part XI - 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
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 I - Transcript.pdf
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part VI.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdf

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Empathic Computing: Creating Shared Understanding
PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation
“AI and Expert System Decision Support & Business Intelligence Systems”
sap open course for s4hana steps from ECC to s4
Network Security Unit 5.pdf for BCA BBA.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars

Creating a Facebook Clone - Part XL.pdf

  • 1. Creating a Facebook Clone - Part XL
  • 2. public class Post implements PropertyBusinessObject { public final Property<String, Post> id = new Property<>("id"); public final Property<User, Post> user = new Property<>("user", User.class); public final LongProperty<Post> date = new LongProperty<>("date"); public final Property<String, Post> title = new Property<>("title"); public final Property<String, Post> content = new Property<>("content"); public final Property<String, Post> visibility = new Property<>("visibility"); public final Property<String, Post> styling = new Property<>("styling"); public final ListProperty<Comment, Post> comments = new ListProperty<>("comments", Comment.class); public final ListProperty<User, Post> likes = new ListProperty<>("likes", User.class); public final MapProperty<String, String, Post> attachments = new MapProperty<>("attachments", String.class, String.class); private final PropertyIndex idx = new PropertyIndex(this, "Post", id, user, date, title, content, visibility, styling, comments, likes, attachments); Post
  • 3. public class Post implements PropertyBusinessObject { public final Property<String, Post> id = new Property<>("id"); public final Property<User, Post> user = new Property<>("user", User.class); public final LongProperty<Post> date = new LongProperty<>("date"); public final Property<String, Post> title = new Property<>("title"); public final Property<String, Post> content = new Property<>("content"); public final Property<String, Post> visibility = new Property<>("visibility"); public final Property<String, Post> styling = new Property<>("styling"); public final ListProperty<Comment, Post> comments = new ListProperty<>("comments", Comment.class); public final ListProperty<User, Post> likes = new ListProperty<>("likes", User.class); public final MapProperty<String, String, Post> attachments = new MapProperty<>("attachments", String.class, String.class); private final PropertyIndex idx = new PropertyIndex(this, "Post", id, user, date, title, content, visibility, styling, comments, likes, attachments); Post
  • 4. Response<String> s = post("user/contacts"). body(contactsToJSON(contacts)).getAsString(); return "OK".equals(s.getResponseData()); } public static MultipartRequest uploadMedia(String mime, String role, String visibility, String fileName, byte[] data, SuccessCallback<String> callback) { MultipartRequest mp = new MultipartRequest() { private String mediaId; @Override protected void readResponse(InputStream input) throws IOException { mediaId = Util.readToString(input); } @Override protected void postResponse() { callback.onSucess(mediaId); } }; mp.setUrl(BASE_URL + "media/upload"); mp.addRequestHeader("auth", token); ServerAPI
  • 5. Response<String> s = post("user/contacts"). body(contactsToJSON(contacts)).getAsString(); return "OK".equals(s.getResponseData()); } public static MultipartRequest uploadMedia(String mime, String role, String visibility, String fileName, byte[] data, SuccessCallback<String> callback) { MultipartRequest mp = new MultipartRequest() { private String mediaId; @Override protected void readResponse(InputStream input) throws IOException { mediaId = Util.readToString(input); } @Override protected void postResponse() { callback.onSucess(mediaId); } }; mp.setUrl(BASE_URL + "media/upload"); mp.addRequestHeader("auth", token); ServerAPI
  • 6. @Override protected void postResponse() { callback.onSucess(mediaId); } }; mp.setUrl(BASE_URL + "media/upload"); mp.addRequestHeader("auth", token); mp.addRequestHeader("Accept", "application/json"); mp.addArgument("role", role); mp.addArgument("visibility", visibility); if(data == null) { try { mp.addData("file", fileName, mime); } catch(IOException err) { Log.e(err); throw new RuntimeException(err); } } else { mp.addData("file", data, mime); } mp.setFilename("file", fileName); addToQueue(mp); return mp; ServerAPI