SlideShare a Scribd company logo
1 of 15
Download to read offline
Creating an Uber Clone - Part XXIV
Now that we have a path on the map we can move forward to the hailing process
Hailing
© Codename One 2017 all rights reserved
The hailing process is relatively simple, we tint the UI show a beacon and during that time we ask the server for a car.
blackButton.addActionListener(e -> {
exitNavigationMode(layer, fromComponent, toComponent, pathObject);
Label searching = new Label("Finding your ride",
Resources.getGlobalResources().getImage("searching-cab-icon.png"),
"SearchingDialog");
pinLayer.add(SOUTH, searching);
pinLayer.getUnselectedStyle().setBgColor(0);
pinLayer.getUnselectedStyle().setBgTransparency(120);
pinLayer.add(CENTER, new BlinkDot());
LocationService.hailRide(from, to, car -> {
pinLayer.getUnselectedStyle().setBgTransparency(0);
pinLayer.removeAll();
});
});
enterNavigationMode
We can start by adding an event handler to the blackButton from the enterNavigationMode method

We are effectively coloring the pin layer to create the tint effect
blackButton.addActionListener(e -> {
exitNavigationMode(layer, fromComponent, toComponent, pathObject);
Label searching = new Label("Finding your ride",
Resources.getGlobalResources().getImage("searching-cab-icon.png"),
"SearchingDialog");
pinLayer.add(SOUTH, searching);
pinLayer.getUnselectedStyle().setBgColor(0);
pinLayer.getUnselectedStyle().setBgTransparency(120);
pinLayer.add(CENTER, new BlinkDot());
LocationService.hailRide(from, to, car -> {
pinLayer.getUnselectedStyle().setBgTransparency(0);
pinLayer.removeAll();
});
});
enterNavigationMode
We added a new BlinkDot class to implement the pulsing blue dot effect
blackButton.addActionListener(e -> {
exitNavigationMode(layer, fromComponent, toComponent, pathObject);
Label searching = new Label("Finding your ride",
Resources.getGlobalResources().getImage("searching-cab-icon.png"),
"SearchingDialog");
pinLayer.add(SOUTH, searching);
pinLayer.getUnselectedStyle().setBgColor(0);
pinLayer.getUnselectedStyle().setBgTransparency(120);
pinLayer.add(CENTER, new BlinkDot());
LocationService.hailRide(from, to, car -> {
pinLayer.getUnselectedStyle().setBgTransparency(0);
pinLayer.removeAll();
});
});
enterNavigationMode
Another new API the hailRide method in LocationService allows us to hail a ride...
blackButton.addActionListener(e -> {
exitNavigationMode(layer, fromComponent, toComponent, pathObject);
Label searching = new Label("Finding your ride",
Resources.getGlobalResources().getImage("searching-cab-icon.png"),
"SearchingDialog");
pinLayer.add(SOUTH, searching);
pinLayer.getUnselectedStyle().setBgColor(0);
pinLayer.getUnselectedStyle().setBgTransparency(120);
pinLayer.add(CENTER, new BlinkDot());
LocationService.hailRide(from, to, car -> {
pinLayer.getUnselectedStyle().setBgTransparency(0);
pinLayer.removeAll();
});
});
enterNavigationMode
Notice I don't show anything when the ride is hailed, I'll add that workflow with the driver app later
SearchingDialog
© Codename One 2017 all rights reserved
There is one UIID we need to cover here and it's the SearchingDialog UIID. Technically this UI element isn't a Dialog it's a Label but it looks like a Dialog.
SearchingDialog
© Codename One 2017 all rights reserved
Padding is pretty standard for a label
SearchingDialog
© Codename One 2017 all rights reserved
We have some margin on the sides to space it out from the edges
SearchingDialog
© Codename One 2017 all rights reserved
Most of this UIID is pretty standard except for the use of the special mode of the RoundRectBorder. The top only mode allows only the top portion to be rounded and the
bottom appears square. Usually we use it to combine two borders together with different colors or UIID’s. In this case we give the component a feel of “peeking” from the
bottom of the Form.
SearchingDialog
© Codename One 2017 all rights reserved
The font is the standard font just like any other label
public class BlinkDot extends Component {
private int value;
private Motion growth;
public BlinkDot() {
setUIID("Label");
}
@Override
protected void initComponent() {
super.initComponent();
getComponentForm().registerAnimated(this);
}
@Override
protected void deinitialize() {
getComponentForm().deregisterAnimated(this);
super.deinitialize();
}
@Override
public boolean animate() {
if(growth == null || growth.isFinished()) {
growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000);
growth.start();
}
int newValue = growth.getValue();
if(newValue != value) {
value = newValue;
return true;
}
BlinkDot
The BlinkDot class is pretty trivial. I could have used an animated gif but instead I just did this.

This is mostly for transparency we don't really use the UIID here
public class BlinkDot extends Component {
private int value;
private Motion growth;
public BlinkDot() {
setUIID("Label");
}
@Override
protected void initComponent() {
super.initComponent();
getComponentForm().registerAnimated(this);
}
@Override
protected void deinitialize() {
getComponentForm().deregisterAnimated(this);
super.deinitialize();
}
@Override
public boolean animate() {
if(growth == null || growth.isFinished()) {
growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000);
growth.start();
}
int newValue = growth.getValue();
if(newValue != value) {
value = newValue;
return true;
}
BlinkDot
I use low level animations here so the best practice is to register/remove with initComponent/deinitialize
public class BlinkDot extends Component {
private int value;
private Motion growth;
public BlinkDot() {
setUIID("Label");
}
@Override
protected void initComponent() {
super.initComponent();
getComponentForm().registerAnimated(this);
}
@Override
protected void deinitialize() {
getComponentForm().deregisterAnimated(this);
super.deinitialize();
}
@Override
public boolean animate() {
if(growth == null || growth.isFinished()) {
growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000);
growth.start();
}
int newValue = growth.getValue();
if(newValue != value) {
value = newValue;
return true;
}
BlinkDot
The motion class represents a timed motion between values which allows us to animate a value from point X to point Y. In this case I'm just growing the circle using the
value. Notice only the animate method mutates values as the paint method can be invoked more than once per cycle in theory
growth.start();
}
int newValue = growth.getValue();
if(newValue != value) {
value = newValue;
return true;
}
return false;
}
@Override
public void paint(Graphics g) {
g.setAlpha(255);
g.setColor(0x297aa7);
int s = convertToPixels(2);
g.setAntiAliased(true);
g.fillArc(getX() + getWidth() / 2 - s / 2, getY() + getHeight() / 2 -
s / 2, s, s, 0, 360);
g.drawArc(getX() + getWidth() / 2 - value,
getY() + getHeight() / 2 - value, value * 2, value * 2, 0, 360);
g.drawArc(getX() + getWidth() / 2 - value - 1, getY() + getHeight() / 2 -
value - 1, value * 2 + 1, value * 2 + 1, 0, 360);
}
@Override
protected Dimension calcPreferredSize() {
int s = convertToPixels(15);
return new Dimension(s, s);
}
BlinkDot
The drawing logic is mostly hardcoded, I would have used the shape API to get a more refined effect but it would have made things more complicated

More Related Content

Similar to Creating an Uber Clone - Part XXIV - Transcript.pdf

Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAlexey Frolov
 
[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshellBeMyApp
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads France
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataAutodesk
 
Animations - Part 3.pdf
Animations - Part 3.pdfAnimations - Part 3.pdf
Animations - Part 3.pdfShaiAlmog1
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesSamsung Developers
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenesBinary Studio
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsNaman Dwivedi
 
303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Codejonmarimba
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfNuttavutThongjor1
 
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)anistar sung
 
io 19 extended android flutter&mlkit
io 19 extended android flutter&mlkitio 19 extended android flutter&mlkit
io 19 extended android flutter&mlkit성윤 (Hunt) 조
 
Animations - Part 1.pdf
Animations - Part 1.pdfAnimations - Part 1.pdf
Animations - Part 1.pdfShaiAlmog1
 

Similar to Creating an Uber Clone - Part XXIV - Transcript.pdf (20)

Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
 
[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell[Ultracode Munich Meetup #7] Android view customization in a nutshell
[Ultracode Munich Meetup #7] Android view customization in a nutshell
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design Data
 
Animations - Part 3.pdf
Animations - Part 3.pdfAnimations - Part 3.pdf
Animations - Part 3.pdf
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and Gestures
 
Academy PRO: React native - building first scenes
Academy PRO: React native - building first scenesAcademy PRO: React native - building first scenes
Academy PRO: React native - building first scenes
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
20151224-games
20151224-games20151224-games
20151224-games
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
 
303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdf
 
mobl
moblmobl
mobl
 
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
 
io 19 extended android flutter&mlkit
io 19 extended android flutter&mlkitio 19 extended android flutter&mlkit
io 19 extended android flutter&mlkit
 
Animations - Part 1.pdf
Animations - Part 1.pdfAnimations - Part 1.pdf
Animations - Part 1.pdf
 

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-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfShaiAlmog1
 
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
 

More from ShaiAlmog1 (20)

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

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Creating an Uber Clone - Part XXIV - Transcript.pdf

  • 1. Creating an Uber Clone - Part XXIV Now that we have a path on the map we can move forward to the hailing process
  • 2. Hailing © Codename One 2017 all rights reserved The hailing process is relatively simple, we tint the UI show a beacon and during that time we ask the server for a car.
  • 3. blackButton.addActionListener(e -> { exitNavigationMode(layer, fromComponent, toComponent, pathObject); Label searching = new Label("Finding your ride", Resources.getGlobalResources().getImage("searching-cab-icon.png"), "SearchingDialog"); pinLayer.add(SOUTH, searching); pinLayer.getUnselectedStyle().setBgColor(0); pinLayer.getUnselectedStyle().setBgTransparency(120); pinLayer.add(CENTER, new BlinkDot()); LocationService.hailRide(from, to, car -> { pinLayer.getUnselectedStyle().setBgTransparency(0); pinLayer.removeAll(); }); }); enterNavigationMode We can start by adding an event handler to the blackButton from the enterNavigationMode method We are effectively coloring the pin layer to create the tint effect
  • 4. blackButton.addActionListener(e -> { exitNavigationMode(layer, fromComponent, toComponent, pathObject); Label searching = new Label("Finding your ride", Resources.getGlobalResources().getImage("searching-cab-icon.png"), "SearchingDialog"); pinLayer.add(SOUTH, searching); pinLayer.getUnselectedStyle().setBgColor(0); pinLayer.getUnselectedStyle().setBgTransparency(120); pinLayer.add(CENTER, new BlinkDot()); LocationService.hailRide(from, to, car -> { pinLayer.getUnselectedStyle().setBgTransparency(0); pinLayer.removeAll(); }); }); enterNavigationMode We added a new BlinkDot class to implement the pulsing blue dot effect
  • 5. blackButton.addActionListener(e -> { exitNavigationMode(layer, fromComponent, toComponent, pathObject); Label searching = new Label("Finding your ride", Resources.getGlobalResources().getImage("searching-cab-icon.png"), "SearchingDialog"); pinLayer.add(SOUTH, searching); pinLayer.getUnselectedStyle().setBgColor(0); pinLayer.getUnselectedStyle().setBgTransparency(120); pinLayer.add(CENTER, new BlinkDot()); LocationService.hailRide(from, to, car -> { pinLayer.getUnselectedStyle().setBgTransparency(0); pinLayer.removeAll(); }); }); enterNavigationMode Another new API the hailRide method in LocationService allows us to hail a ride...
  • 6. blackButton.addActionListener(e -> { exitNavigationMode(layer, fromComponent, toComponent, pathObject); Label searching = new Label("Finding your ride", Resources.getGlobalResources().getImage("searching-cab-icon.png"), "SearchingDialog"); pinLayer.add(SOUTH, searching); pinLayer.getUnselectedStyle().setBgColor(0); pinLayer.getUnselectedStyle().setBgTransparency(120); pinLayer.add(CENTER, new BlinkDot()); LocationService.hailRide(from, to, car -> { pinLayer.getUnselectedStyle().setBgTransparency(0); pinLayer.removeAll(); }); }); enterNavigationMode Notice I don't show anything when the ride is hailed, I'll add that workflow with the driver app later
  • 7. SearchingDialog © Codename One 2017 all rights reserved There is one UIID we need to cover here and it's the SearchingDialog UIID. Technically this UI element isn't a Dialog it's a Label but it looks like a Dialog.
  • 8. SearchingDialog © Codename One 2017 all rights reserved Padding is pretty standard for a label
  • 9. SearchingDialog © Codename One 2017 all rights reserved We have some margin on the sides to space it out from the edges
  • 10. SearchingDialog © Codename One 2017 all rights reserved Most of this UIID is pretty standard except for the use of the special mode of the RoundRectBorder. The top only mode allows only the top portion to be rounded and the bottom appears square. Usually we use it to combine two borders together with different colors or UIID’s. In this case we give the component a feel of “peeking” from the bottom of the Form.
  • 11. SearchingDialog © Codename One 2017 all rights reserved The font is the standard font just like any other label
  • 12. public class BlinkDot extends Component { private int value; private Motion growth; public BlinkDot() { setUIID("Label"); } @Override protected void initComponent() { super.initComponent(); getComponentForm().registerAnimated(this); } @Override protected void deinitialize() { getComponentForm().deregisterAnimated(this); super.deinitialize(); } @Override public boolean animate() { if(growth == null || growth.isFinished()) { growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000); growth.start(); } int newValue = growth.getValue(); if(newValue != value) { value = newValue; return true; } BlinkDot The BlinkDot class is pretty trivial. I could have used an animated gif but instead I just did this. This is mostly for transparency we don't really use the UIID here
  • 13. public class BlinkDot extends Component { private int value; private Motion growth; public BlinkDot() { setUIID("Label"); } @Override protected void initComponent() { super.initComponent(); getComponentForm().registerAnimated(this); } @Override protected void deinitialize() { getComponentForm().deregisterAnimated(this); super.deinitialize(); } @Override public boolean animate() { if(growth == null || growth.isFinished()) { growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000); growth.start(); } int newValue = growth.getValue(); if(newValue != value) { value = newValue; return true; } BlinkDot I use low level animations here so the best practice is to register/remove with initComponent/deinitialize
  • 14. public class BlinkDot extends Component { private int value; private Motion growth; public BlinkDot() { setUIID("Label"); } @Override protected void initComponent() { super.initComponent(); getComponentForm().registerAnimated(this); } @Override protected void deinitialize() { getComponentForm().deregisterAnimated(this); super.deinitialize(); } @Override public boolean animate() { if(growth == null || growth.isFinished()) { growth = Motion.createEaseInOutMotion(3, getWidth() / 2, 1000); growth.start(); } int newValue = growth.getValue(); if(newValue != value) { value = newValue; return true; } BlinkDot The motion class represents a timed motion between values which allows us to animate a value from point X to point Y. In this case I'm just growing the circle using the value. Notice only the animate method mutates values as the paint method can be invoked more than once per cycle in theory
  • 15. growth.start(); } int newValue = growth.getValue(); if(newValue != value) { value = newValue; return true; } return false; } @Override public void paint(Graphics g) { g.setAlpha(255); g.setColor(0x297aa7); int s = convertToPixels(2); g.setAntiAliased(true); g.fillArc(getX() + getWidth() / 2 - s / 2, getY() + getHeight() / 2 - s / 2, s, s, 0, 360); g.drawArc(getX() + getWidth() / 2 - value, getY() + getHeight() / 2 - value, value * 2, value * 2, 0, 360); g.drawArc(getX() + getWidth() / 2 - value - 1, getY() + getHeight() / 2 - value - 1, value * 2 + 1, value * 2 + 1, 0, 360); } @Override protected Dimension calcPreferredSize() { int s = convertToPixels(15); return new Dimension(s, s); } BlinkDot The drawing logic is mostly hardcoded, I would have used the shape API to get a more refined effect but it would have made things more complicated