SlideShare a Scribd company logo
1 of 14
Download to read offline
Creating a Facebook Clone - Part XXXIX
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
public void pickImage(SuccessCallback<EncodedImage> onPick) {
pick(onPick, null);
}
public void pick(SuccessCallback<EncodedImage> onImage,
SuccessCallback<Media> onVideo) {
Display.getInstance().openGallery(e -> {
if(e == null) {
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
ImagePicker
pick(onPick, null);
}
public void pick(SuccessCallback<EncodedImage> onImage,
SuccessCallback<Media> onVideo) {
Display.getInstance().openGallery(e -> {
if(e == null) {
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
ImagePicker
pick(onPick, null);
}
public void pick(SuccessCallback<EncodedImage> onImage,
SuccessCallback<Media> onVideo) {
Display.getInstance().openGallery(e -> {
if(e == null) {
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
ImagePicker
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
onVideo.onSucess(m);
}
} catch(IOException err) {
Log.e(err);
}
}, mode);
}
ImagePicker
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
onVideo.onSucess(m);
}
} catch(IOException err) {
Log.e(err);
}
}, mode);
}
ImagePicker
return;
}
String s = (String)e.getSource();
if(s == null) {
return;
}
try {
String sl = s.toLowerCase();
fileName = s;
if(sl.endsWith("jpeg") || sl.endsWith("jpg") ||
sl.endsWith("png")) {
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
onVideo.onSucess(m);
}
} catch(IOException err) {
Log.e(err);
}
}, mode);
}
ImagePicker
try(InputStream i = openFileInputStream(s);) {
img = EncodedImage.create(i, (int)getFileLength(s));
onImage.onSucess(img);
}
} else {
Media m = MediaManager.createMedia(s, true);
onVideo.onSucess(m);
}
} catch(IOException err) {
Log.e(err);
}
}, mode);
}
public MultipartRequest upload(SuccessCallback<String> mediaId) {
if(img != null) {
return ServerAPI.uploadMedia("image/jpeg", "photo", "public",
fileName, img.getImageData(), mediaId);
} else {
return ServerAPI.uploadMedia("video/mp4", "video", "public",
fileName, null, mediaId);
}
}
ImagePicker
} else {
Media m = MediaManager.createMedia(s, true);
onVideo.onSucess(m);
}
} catch(IOException err) {
Log.e(err);
}
}, mode);
}
public MultipartRequest upload(SuccessCallback<String> mediaId) {
if(img != null) {
return ServerAPI.uploadMedia("image/jpeg", "photo", "public",
fileName, img.getImageData(), mediaId);
} else {
return ServerAPI.uploadMedia("video/mp4", "video", "public",
fileName, null, mediaId);
}
}
public EncodedImage getImage() {
return img;
}
}
ImagePicker
public ImagePicker(int mode) {
this.mode = mode;
}
public static ImagePicker create(String fileName) {
ImagePicker p = new ImagePicker();
try(InputStream i = openFileInputStream(fileName)) {
p.img = EncodedImage.create(i, (int)getFileLength(fileName));
p.fileName = fileName;
return p;
} catch(IOException err) {
Log.e(err);
return null;
}
}
public static ImagePicker create(byte[] data) {
ImagePicker p = new ImagePicker();
p.img = EncodedImage.create(data);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
ImagePicker
public ImagePicker(int mode) {
this.mode = mode;
}
public static ImagePicker create(String fileName) {
ImagePicker p = new ImagePicker();
try(InputStream i = openFileInputStream(fileName)) {
p.img = EncodedImage.create(i, (int)getFileLength(fileName));
p.fileName = fileName;
return p;
} catch(IOException err) {
Log.e(err);
return null;
}
}
public static ImagePicker create(byte[] data) {
ImagePicker p = new ImagePicker();
p.img = EncodedImage.create(data);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
ImagePicker
public ImagePicker(int mode) {
this.mode = mode;
}
public static ImagePicker create(String fileName) {
ImagePicker p = new ImagePicker();
try(InputStream i = openFileInputStream(fileName)) {
p.img = EncodedImage.create(i, (int)getFileLength(fileName));
p.fileName = fileName;
return p;
} catch(IOException err) {
Log.e(err);
return null;
}
}
public static ImagePicker create(byte[] data) {
ImagePicker p = new ImagePicker();
p.img = EncodedImage.create(data);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
ImagePicker
public ImagePicker(int mode) {
this.mode = mode;
}
public static ImagePicker create(String fileName) {
ImagePicker p = new ImagePicker();
try(InputStream i = openFileInputStream(fileName)) {
p.img = EncodedImage.create(i, (int)getFileLength(fileName));
p.fileName = fileName;
return p;
} catch(IOException err) {
Log.e(err);
return null;
}
}
public static ImagePicker create(byte[] data) {
ImagePicker p = new ImagePicker();
p.img = EncodedImage.create(data);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
ImagePicker
public ImagePicker(int mode) {
this.mode = mode;
}
public static ImagePicker create(String fileName) {
ImagePicker p = new ImagePicker();
try(InputStream i = openFileInputStream(fileName)) {
p.img = EncodedImage.create(i, (int)getFileLength(fileName));
p.fileName = fileName;
return p;
} catch(IOException err) {
Log.e(err);
return null;
}
}
public static ImagePicker create(byte[] data) {
ImagePicker p = new ImagePicker();
p.img = EncodedImage.create(data);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm");
p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg";
return p;
}
ImagePicker

More Related Content

Similar to Creating a Facebook Clone - Part XXXIX.pdf

I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdffeelinggifts
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab workShajun Nisha
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision DetectionJenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
Creating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfCreating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
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.pdfShaiAlmog1
 
A comprehensive tutorial to upload, cache, save and share image in Android apps
A comprehensive tutorial to upload, cache, save and share image in Android appsA comprehensive tutorial to upload, cache, save and share image in Android apps
A comprehensive tutorial to upload, cache, save and share image in Android appsZuaib
 
Below are questions that use the following image class- import assert.pdf
Below are questions that use the following image class-  import assert.pdfBelow are questions that use the following image class-  import assert.pdf
Below are questions that use the following image class- import assert.pdfrdzire2014
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
Creating a Facebook Clone - Part XLII - Transcript.pdf
Creating a Facebook Clone - Part XLII - Transcript.pdfCreating a Facebook Clone - Part XLII - Transcript.pdf
Creating a Facebook Clone - Part XLII - Transcript.pdfShaiAlmog1
 
MySQL User Conference 2009: Python and MySQL
MySQL User Conference 2009: Python and MySQLMySQL User Conference 2009: Python and MySQL
MySQL User Conference 2009: Python and MySQLTed Leung
 
Creating an Uber Clone - Part XXIV.pdf
Creating an Uber Clone - Part XXIV.pdfCreating an Uber Clone - Part XXIV.pdf
Creating an Uber Clone - Part XXIV.pdfShaiAlmog1
 
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефонаКурсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефонаГлеб Тарасов
 

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

I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdf
 
Vanmathy python
Vanmathy python Vanmathy python
Vanmathy python
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab work
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
From newbie to ...
From newbie to ...From newbie to ...
From newbie to ...
 
Creating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfCreating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.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
 
Java oops features
Java oops featuresJava oops features
Java oops features
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
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
 
662305 11
662305 11662305 11
662305 11
 
A comprehensive tutorial to upload, cache, save and share image in Android apps
A comprehensive tutorial to upload, cache, save and share image in Android appsA comprehensive tutorial to upload, cache, save and share image in Android apps
A comprehensive tutorial to upload, cache, save and share image in Android apps
 
Pygame presentation
Pygame presentationPygame presentation
Pygame presentation
 
Below are questions that use the following image class- import assert.pdf
Below are questions that use the following image class-  import assert.pdfBelow are questions that use the following image class-  import assert.pdf
Below are questions that use the following image class- import assert.pdf
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Creating a Facebook Clone - Part XLII - Transcript.pdf
Creating a Facebook Clone - Part XLII - Transcript.pdfCreating a Facebook Clone - Part XLII - Transcript.pdf
Creating a Facebook Clone - Part XLII - Transcript.pdf
 
MySQL User Conference 2009: Python and MySQL
MySQL User Conference 2009: Python and MySQLMySQL User Conference 2009: Python and MySQL
MySQL User Conference 2009: Python and MySQL
 
Creating an Uber Clone - Part XXIV.pdf
Creating an Uber Clone - Part XXIV.pdfCreating an Uber Clone - Part XXIV.pdf
Creating an Uber Clone - Part XXIV.pdf
 
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефонаКурсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
 

More from ShaiAlmog1

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 ...ShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
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.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfShaiAlmog1
 

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-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
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdf
 

Recently uploaded

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Creating a Facebook Clone - Part XXXIX.pdf

  • 1. Creating a Facebook Clone - Part XXXIX
  • 2. SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } public void pickImage(SuccessCallback<EncodedImage> onPick) { pick(onPick, null); } public void pick(SuccessCallback<EncodedImage> onImage, SuccessCallback<Media> onVideo) { Display.getInstance().openGallery(e -> { if(e == null) { return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { ImagePicker
  • 3. pick(onPick, null); } public void pick(SuccessCallback<EncodedImage> onImage, SuccessCallback<Media> onVideo) { Display.getInstance().openGallery(e -> { if(e == null) { return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); ImagePicker
  • 4. pick(onPick, null); } public void pick(SuccessCallback<EncodedImage> onImage, SuccessCallback<Media> onVideo) { Display.getInstance().openGallery(e -> { if(e == null) { return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); ImagePicker
  • 5. return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); onVideo.onSucess(m); } } catch(IOException err) { Log.e(err); } }, mode); } ImagePicker
  • 6. return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); onVideo.onSucess(m); } } catch(IOException err) { Log.e(err); } }, mode); } ImagePicker
  • 7. return; } String s = (String)e.getSource(); if(s == null) { return; } try { String sl = s.toLowerCase(); fileName = s; if(sl.endsWith("jpeg") || sl.endsWith("jpg") || sl.endsWith("png")) { try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); onVideo.onSucess(m); } } catch(IOException err) { Log.e(err); } }, mode); } ImagePicker
  • 8. try(InputStream i = openFileInputStream(s);) { img = EncodedImage.create(i, (int)getFileLength(s)); onImage.onSucess(img); } } else { Media m = MediaManager.createMedia(s, true); onVideo.onSucess(m); } } catch(IOException err) { Log.e(err); } }, mode); } public MultipartRequest upload(SuccessCallback<String> mediaId) { if(img != null) { return ServerAPI.uploadMedia("image/jpeg", "photo", "public", fileName, img.getImageData(), mediaId); } else { return ServerAPI.uploadMedia("video/mp4", "video", "public", fileName, null, mediaId); } } ImagePicker
  • 9. } else { Media m = MediaManager.createMedia(s, true); onVideo.onSucess(m); } } catch(IOException err) { Log.e(err); } }, mode); } public MultipartRequest upload(SuccessCallback<String> mediaId) { if(img != null) { return ServerAPI.uploadMedia("image/jpeg", "photo", "public", fileName, img.getImageData(), mediaId); } else { return ServerAPI.uploadMedia("video/mp4", "video", "public", fileName, null, mediaId); } } public EncodedImage getImage() { return img; } } ImagePicker
  • 10. public ImagePicker(int mode) { this.mode = mode; } public static ImagePicker create(String fileName) { ImagePicker p = new ImagePicker(); try(InputStream i = openFileInputStream(fileName)) { p.img = EncodedImage.create(i, (int)getFileLength(fileName)); p.fileName = fileName; return p; } catch(IOException err) { Log.e(err); return null; } } public static ImagePicker create(byte[] data) { ImagePicker p = new ImagePicker(); p.img = EncodedImage.create(data); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } ImagePicker
  • 11. public ImagePicker(int mode) { this.mode = mode; } public static ImagePicker create(String fileName) { ImagePicker p = new ImagePicker(); try(InputStream i = openFileInputStream(fileName)) { p.img = EncodedImage.create(i, (int)getFileLength(fileName)); p.fileName = fileName; return p; } catch(IOException err) { Log.e(err); return null; } } public static ImagePicker create(byte[] data) { ImagePicker p = new ImagePicker(); p.img = EncodedImage.create(data); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } ImagePicker
  • 12. public ImagePicker(int mode) { this.mode = mode; } public static ImagePicker create(String fileName) { ImagePicker p = new ImagePicker(); try(InputStream i = openFileInputStream(fileName)) { p.img = EncodedImage.create(i, (int)getFileLength(fileName)); p.fileName = fileName; return p; } catch(IOException err) { Log.e(err); return null; } } public static ImagePicker create(byte[] data) { ImagePicker p = new ImagePicker(); p.img = EncodedImage.create(data); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } ImagePicker
  • 13. public ImagePicker(int mode) { this.mode = mode; } public static ImagePicker create(String fileName) { ImagePicker p = new ImagePicker(); try(InputStream i = openFileInputStream(fileName)) { p.img = EncodedImage.create(i, (int)getFileLength(fileName)); p.fileName = fileName; return p; } catch(IOException err) { Log.e(err); return null; } } public static ImagePicker create(byte[] data) { ImagePicker p = new ImagePicker(); p.img = EncodedImage.create(data); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } ImagePicker
  • 14. public ImagePicker(int mode) { this.mode = mode; } public static ImagePicker create(String fileName) { ImagePicker p = new ImagePicker(); try(InputStream i = openFileInputStream(fileName)) { p.img = EncodedImage.create(i, (int)getFileLength(fileName)); p.fileName = fileName; return p; } catch(IOException err) { Log.e(err); return null; } } public static ImagePicker create(byte[] data) { ImagePicker p = new ImagePicker(); p.img = EncodedImage.create(data); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HHmm"); p.fileName = "camera-photo " + sd.format(new Date()) + ".jpeg"; return p; } ImagePicker