SlideShare a Scribd company logo
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 example
Alexey 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 nutshell
BeMyApp
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads 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 Data
Autodesk
 
Animations - Part 3.pdf
Animations - Part 3.pdfAnimations - Part 3.pdf
Animations - Part 3.pdf
ShaiAlmog1
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
cagataycivici
 
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
Samsung 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 scenes
Binary 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 development
anistar sung
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
Naman Dwivedi
 
20151224-games
20151224-games20151224-games
20151224-games
Noritada Shimizu
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
GlobalLogic Ukraine
 
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
jonmarimba
 
[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.pdf
NuttavutThongjor1
 
mobl
moblmobl
mobl
zefhemel
 
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.pdf
ShaiAlmog1
 

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.pdf
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.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 
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
ShaiAlmog1
 

More from ShaiAlmog1 (20)

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

Recently uploaded

Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 

Recently uploaded (20)

Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 

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