SlideShare a Scribd company logo
1 of 16
Download to read offline
Creating an Uber Clone - Part XXI
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
private MapContainer mc;
private AutoCompleteAddressInput lastFocused;
private MapListener lastMapListener;
private UITimer lastTimer;
private Button whereTo;
private Container mapLayer;
private boolean inNavigationMode;
MapForm
void showNavigationToolbar() {
final Container layer = getLayeredPane(MapForm.class, true);
layer.setName("MapFormLayer");
layer.setLayout(new BorderLayout());
final Container pinLayer = getLayeredPane(AutoCompleteAddressInput.class, false);
pinLayer.setName("PinLayer");
pinLayer.setLayout(new BorderLayout(CENTER_BEHAVIOR_CENTER_ABSOLUTE));
Image pin = Resources.getGlobalResources().getImage("Pin.png");
Label pinLabel = new Label(pin);
MapLayout.setHorizontalAlignment(pinLabel, MapLayout.HALIGN.CENTER);
MapLayout.setVerticalAlignment(pinLabel, MapLayout.VALIGN.BOTTOM);
pinLayer.add(CENTER, pinLabel);
Button back = new Button("", "TitleCommand");
FontImage.setMaterialIcon(back, FontImage.MATERIAL_ARROW_BACK);
CompletionContainer cc = new CompletionContainer();
AutoCompleteAddressInput from =
new AutoCompleteAddressInput("Current Location", "From",layer,cc);
AutoCompleteAddressInput to =
new AutoCompleteAddressInput("", "Where To?", layer, cc);
from.setCurrentLocation(LocationService.getCurrentLocation());
Image circle = Image.createImage(square.getWidth(),square.getHeight(),0);
Graphics g = circle.getGraphics();
showNavigationToolbar
void showNavigationToolbar() {
final Container layer = getLayeredPane(MapForm.class, true);
layer.setName("MapFormLayer");
layer.setLayout(new BorderLayout());
final Container pinLayer = getLayeredPane(AutoCompleteAddressInput.class, false);
pinLayer.setName("PinLayer");
pinLayer.setLayout(new BorderLayout(CENTER_BEHAVIOR_CENTER_ABSOLUTE));
Image pin = Resources.getGlobalResources().getImage("Pin.png");
Label pinLabel = new Label(pin);
MapLayout.setHorizontalAlignment(pinLabel, MapLayout.HALIGN.CENTER);
MapLayout.setVerticalAlignment(pinLabel, MapLayout.VALIGN.BOTTOM);
pinLayer.add(CENTER, pinLabel);
Button back = new Button("", "TitleCommand");
FontImage.setMaterialIcon(back, FontImage.MATERIAL_ARROW_BACK);
CompletionContainer cc = new CompletionContainer();
AutoCompleteAddressInput from =
new AutoCompleteAddressInput("Current Location", "From",layer,cc);
AutoCompleteAddressInput to =
new AutoCompleteAddressInput("", "Where To?", layer, cc);
from.setCurrentLocation(LocationService.getCurrentLocation());
Image circle = Image.createImage(square.getWidth(),square.getHeight(),0);
Graphics g = circle.getGraphics();
showNavigationToolbar
from.setCurrentLocation(LocationService.getCurrentLocation());
Image circle = Image.createImage(square.getWidth(),square.getHeight(),0);
Graphics g = circle.getGraphics();
g.setColor(0xa4a4ac);
g.setAntiAliased(true);
g.fillArc(0, 0, circle.getWidth(), circle.getHeight(), 0, 360);
final Label fromSelected = new Label(circle);
final Label toSelected = new Label(square);
SearchService.nameMyCurrentLocation(
LocationService.getCurrentLocation(), name -> from.setTextNoEvent(name));
to.requestFocus();
lastFocused = to;
from.addFocusListener(new FocusListener() {
@Override
public void focusGained(Component cmp) {
fromSelected.setIcon(square);
lastFocused = from;
}
@Override
public void focusLost(Component cmp) {
fromSelected.setIcon(circle);
}
showNavigationToolbar
@Override
public void focusLost(Component cmp) {
toSelected.setIcon(circle);
}
});
addMapListener((source, zoom, center) -> {
if(lastTimer != null) {
lastTimer.cancel();
}
lastTimer = UITimer.timer(500, false, () -> {
lastTimer = null;
SearchService.nameMyCurrentLocation(
new Location(center.getLatitude(), center.getLongitude()),
name -> {
lastFocused.setTextNoEvent(name);
lastFocused.setCurrentLocation(
new Location(center.getLatitude(), center.getLongitude()));
});
});
});
Container navigationToolbar = BoxLayout.encloseY(back,
showNavigationToolbar
lastFocused.setCurrentLocation(
new Location(center.getLatitude(), center.getLongitude()));
});
});
});
Container navigationToolbar = BoxLayout.encloseY(back,
BorderLayout.centerCenterEastWest(from, null, fromSelected),
BorderLayout.centerCenterEastWest(to, null, toSelected)
);
navigationToolbar.setUIID("WhereToToolbar");
navigationToolbar.getUnselectedStyle().setBgPainter((g1, rect) -> {
g1.setAlpha(255);
g1.setColor(0xffffff);
if(dropShadow != null) {
if(((BorderLayout)layer.getLayout()).getCenter() != null) {
g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
}
g1.drawImage(dropShadow, rect.getX() - shadowHeight, rect.getY() +
rect.getHeight() - dropShadow.getHeight() / 4 * 3);
g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getY() +
rect.getHeight() - shadowHeight);
} else {
showNavigationToolbar
g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getY() +
rect.getHeight() - shadowHeight);
} else {
g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
}
g1.setColor(0xa4a4ac);
g1.setAntiAliased(true);
int x = fromSelected.getAbsoluteX() + fromSelected.getWidth() / 2 - 1;
int y = fromSelected.getAbsoluteY() + fromSelected.getHeight() / 2 +
circle.getHeight() / 2;
g1.fillRect(x, y, 2, toSelected.getAbsoluteY() - y +
toSelected.getHeight() / 2 - circle.getHeight() / 2);
});
cc.addCompletionListener(e -> {
if(to.getCurrentLocation() != null) {
SearchService.directions(from.getCurrentLocation(), to.getCurrentLocation(),
(path, duration, distance) -> {
enterNavigationMode(pinLayer, navigationToolbar, layer, path,
from.getText(), to.getText(), duration);
});
}
showNavigationToolbar
SearchService.directions(from.getCurrentLocation(), to.getCurrentLocation(),
(path, duration, distance) -> {
enterNavigationMode(pinLayer, navigationToolbar, layer, path,
from.getText(), to.getText(), duration);
});
}
});
back.addActionListener(e -> {
pinLayer.removeAll();
navigationToolbar.setY(-navigationToolbar.getHeight());
layer.getComponentAt(1).setY(getDisplayHeight());
navigationToolbar.getParent().animateUnlayout(200, 120, () -> {
layer.removeAll();
revalidate();
});
});
layer.add(NORTH, navigationToolbar);
navigationToolbar.setWidth(getDisplayWidth());
navigationToolbar.setHeight(getPreferredH());
navigationToolbar.setY(-navigationToolbar.getHeight());
getAnimationManager().addAnimation(layer.createAnimateLayout(200),
() -> cc.showCompletionBar(layer));
}
showNavigationToolbar
private void addMapListener(MapListener ml) {
if(lastMapListener != null) {
mc.removeMapListener(lastMapListener);
}
lastMapListener = ml;
mc.addMapListener(ml);
}
addMapListener

More Related Content

Similar to Creating an Uber Clone - Part XXI.pdf

Maps - Part 3.pdf
Maps - Part 3.pdfMaps - Part 3.pdf
Maps - Part 3.pdfShaiAlmog1
 
Creating an Uber Clone - Part XVI.pdf
Creating an Uber Clone - Part XVI.pdfCreating an Uber Clone - Part XVI.pdf
Creating an Uber Clone - Part XVI.pdfShaiAlmog1
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhonejonmarimba
 
Creating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfCreating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfShaiAlmog1
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практикеPlatonov Sergey
 
Creating an Uber Clone - Part VII - Transcript.pdf
Creating an Uber Clone - Part VII - Transcript.pdfCreating an Uber Clone - Part VII - Transcript.pdf
Creating an Uber Clone - Part VII - Transcript.pdfShaiAlmog1
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthGeoffrey Goetz
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfShaiAlmog1
 
Gis SAPO Hands On
Gis SAPO Hands OnGis SAPO Hands On
Gis SAPO Hands Oncodebits
 
Sapo GIS Hands-On
Sapo GIS Hands-OnSapo GIS Hands-On
Sapo GIS Hands-Oncodebits
 
Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Martin Kleppe
 
google play service 7.8 & new tech in M
google play service 7.8 & new tech in M google play service 7.8 & new tech in M
google play service 7.8 & new tech in M Ted Liang
 
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
 
Creating an Uber Clone - Part IX.pdf
Creating an Uber Clone - Part IX.pdfCreating an Uber Clone - Part IX.pdf
Creating an Uber Clone - Part IX.pdfShaiAlmog1
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talkshonjo2
 
UI Design From Scratch - Part 5.pdf
UI Design From Scratch - Part 5.pdfUI Design From Scratch - Part 5.pdf
UI Design From Scratch - Part 5.pdfShaiAlmog1
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 

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

Maps - Part 3.pdf
Maps - Part 3.pdfMaps - Part 3.pdf
Maps - Part 3.pdf
 
Creating an Uber Clone - Part XVI.pdf
Creating an Uber Clone - Part XVI.pdfCreating an Uber Clone - Part XVI.pdf
Creating an Uber Clone - Part XVI.pdf
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
 
Creating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfCreating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdf
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
 
Creating an Uber Clone - Part VII - Transcript.pdf
Creating an Uber Clone - Part VII - Transcript.pdfCreating an Uber Clone - Part VII - Transcript.pdf
Creating an Uber Clone - Part VII - Transcript.pdf
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdf
 
Gis SAPO Hands On
Gis SAPO Hands OnGis SAPO Hands On
Gis SAPO Hands On
 
Sapo GIS Hands-On
Sapo GIS Hands-OnSapo GIS Hands-On
Sapo GIS Hands-On
 
Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe
 
google play service 7.8 & new tech in M
google play service 7.8 & new tech in M google play service 7.8 & new tech in M
google play service 7.8 & new tech in M
 
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
 
Creating an Uber Clone - Part IX.pdf
Creating an Uber Clone - Part IX.pdfCreating an Uber Clone - Part IX.pdf
Creating an Uber Clone - Part IX.pdf
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
 
Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
 
Google Maps Api
Google Maps ApiGoogle Maps Api
Google Maps Api
 
Canvas al ajillo
Canvas al ajilloCanvas al ajillo
Canvas al ajillo
 
UI Design From Scratch - Part 5.pdf
UI Design From Scratch - Part 5.pdfUI Design From Scratch - Part 5.pdf
UI Design From Scratch - Part 5.pdf
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 

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

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceIES VE
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 

Recently uploaded (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 

Creating an Uber Clone - Part XXI.pdf

  • 1. Creating an Uber Clone - Part XXI
  • 2. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 3. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 4. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 5. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 6. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 7. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 8. private MapContainer mc; private AutoCompleteAddressInput lastFocused; private MapListener lastMapListener; private UITimer lastTimer; private Button whereTo; private Container mapLayer; private boolean inNavigationMode; MapForm
  • 9. void showNavigationToolbar() { final Container layer = getLayeredPane(MapForm.class, true); layer.setName("MapFormLayer"); layer.setLayout(new BorderLayout()); final Container pinLayer = getLayeredPane(AutoCompleteAddressInput.class, false); pinLayer.setName("PinLayer"); pinLayer.setLayout(new BorderLayout(CENTER_BEHAVIOR_CENTER_ABSOLUTE)); Image pin = Resources.getGlobalResources().getImage("Pin.png"); Label pinLabel = new Label(pin); MapLayout.setHorizontalAlignment(pinLabel, MapLayout.HALIGN.CENTER); MapLayout.setVerticalAlignment(pinLabel, MapLayout.VALIGN.BOTTOM); pinLayer.add(CENTER, pinLabel); Button back = new Button("", "TitleCommand"); FontImage.setMaterialIcon(back, FontImage.MATERIAL_ARROW_BACK); CompletionContainer cc = new CompletionContainer(); AutoCompleteAddressInput from = new AutoCompleteAddressInput("Current Location", "From",layer,cc); AutoCompleteAddressInput to = new AutoCompleteAddressInput("", "Where To?", layer, cc); from.setCurrentLocation(LocationService.getCurrentLocation()); Image circle = Image.createImage(square.getWidth(),square.getHeight(),0); Graphics g = circle.getGraphics(); showNavigationToolbar
  • 10. void showNavigationToolbar() { final Container layer = getLayeredPane(MapForm.class, true); layer.setName("MapFormLayer"); layer.setLayout(new BorderLayout()); final Container pinLayer = getLayeredPane(AutoCompleteAddressInput.class, false); pinLayer.setName("PinLayer"); pinLayer.setLayout(new BorderLayout(CENTER_BEHAVIOR_CENTER_ABSOLUTE)); Image pin = Resources.getGlobalResources().getImage("Pin.png"); Label pinLabel = new Label(pin); MapLayout.setHorizontalAlignment(pinLabel, MapLayout.HALIGN.CENTER); MapLayout.setVerticalAlignment(pinLabel, MapLayout.VALIGN.BOTTOM); pinLayer.add(CENTER, pinLabel); Button back = new Button("", "TitleCommand"); FontImage.setMaterialIcon(back, FontImage.MATERIAL_ARROW_BACK); CompletionContainer cc = new CompletionContainer(); AutoCompleteAddressInput from = new AutoCompleteAddressInput("Current Location", "From",layer,cc); AutoCompleteAddressInput to = new AutoCompleteAddressInput("", "Where To?", layer, cc); from.setCurrentLocation(LocationService.getCurrentLocation()); Image circle = Image.createImage(square.getWidth(),square.getHeight(),0); Graphics g = circle.getGraphics(); showNavigationToolbar
  • 11. from.setCurrentLocation(LocationService.getCurrentLocation()); Image circle = Image.createImage(square.getWidth(),square.getHeight(),0); Graphics g = circle.getGraphics(); g.setColor(0xa4a4ac); g.setAntiAliased(true); g.fillArc(0, 0, circle.getWidth(), circle.getHeight(), 0, 360); final Label fromSelected = new Label(circle); final Label toSelected = new Label(square); SearchService.nameMyCurrentLocation( LocationService.getCurrentLocation(), name -> from.setTextNoEvent(name)); to.requestFocus(); lastFocused = to; from.addFocusListener(new FocusListener() { @Override public void focusGained(Component cmp) { fromSelected.setIcon(square); lastFocused = from; } @Override public void focusLost(Component cmp) { fromSelected.setIcon(circle); } showNavigationToolbar
  • 12. @Override public void focusLost(Component cmp) { toSelected.setIcon(circle); } }); addMapListener((source, zoom, center) -> { if(lastTimer != null) { lastTimer.cancel(); } lastTimer = UITimer.timer(500, false, () -> { lastTimer = null; SearchService.nameMyCurrentLocation( new Location(center.getLatitude(), center.getLongitude()), name -> { lastFocused.setTextNoEvent(name); lastFocused.setCurrentLocation( new Location(center.getLatitude(), center.getLongitude())); }); }); }); Container navigationToolbar = BoxLayout.encloseY(back, showNavigationToolbar
  • 13. lastFocused.setCurrentLocation( new Location(center.getLatitude(), center.getLongitude())); }); }); }); Container navigationToolbar = BoxLayout.encloseY(back, BorderLayout.centerCenterEastWest(from, null, fromSelected), BorderLayout.centerCenterEastWest(to, null, toSelected) ); navigationToolbar.setUIID("WhereToToolbar"); navigationToolbar.getUnselectedStyle().setBgPainter((g1, rect) -> { g1.setAlpha(255); g1.setColor(0xffffff); if(dropShadow != null) { if(((BorderLayout)layer.getLayout()).getCenter() != null) { g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); } g1.drawImage(dropShadow, rect.getX() - shadowHeight, rect.getY() + rect.getHeight() - dropShadow.getHeight() / 4 * 3); g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getY() + rect.getHeight() - shadowHeight); } else { showNavigationToolbar
  • 14. g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getY() + rect.getHeight() - shadowHeight); } else { g1.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); } g1.setColor(0xa4a4ac); g1.setAntiAliased(true); int x = fromSelected.getAbsoluteX() + fromSelected.getWidth() / 2 - 1; int y = fromSelected.getAbsoluteY() + fromSelected.getHeight() / 2 + circle.getHeight() / 2; g1.fillRect(x, y, 2, toSelected.getAbsoluteY() - y + toSelected.getHeight() / 2 - circle.getHeight() / 2); }); cc.addCompletionListener(e -> { if(to.getCurrentLocation() != null) { SearchService.directions(from.getCurrentLocation(), to.getCurrentLocation(), (path, duration, distance) -> { enterNavigationMode(pinLayer, navigationToolbar, layer, path, from.getText(), to.getText(), duration); }); } showNavigationToolbar
  • 15. SearchService.directions(from.getCurrentLocation(), to.getCurrentLocation(), (path, duration, distance) -> { enterNavigationMode(pinLayer, navigationToolbar, layer, path, from.getText(), to.getText(), duration); }); } }); back.addActionListener(e -> { pinLayer.removeAll(); navigationToolbar.setY(-navigationToolbar.getHeight()); layer.getComponentAt(1).setY(getDisplayHeight()); navigationToolbar.getParent().animateUnlayout(200, 120, () -> { layer.removeAll(); revalidate(); }); }); layer.add(NORTH, navigationToolbar); navigationToolbar.setWidth(getDisplayWidth()); navigationToolbar.setHeight(getPreferredH()); navigationToolbar.setY(-navigationToolbar.getHeight()); getAnimationManager().addAnimation(layer.createAnimateLayout(200), () -> cc.showCompletionBar(layer)); } showNavigationToolbar
  • 16. private void addMapListener(MapListener ml) { if(lastMapListener != null) { mc.removeMapListener(lastMapListener); } lastMapListener = ml; mc.addMapListener(ml); } addMapListener