SlideShare a Scribd company logo
Creating an Uber Clone - Part XX
public class CompletionContainer {
private Container result;
private boolean completionUsed;
private final EventDispatcher dispatcher = new EventDispatcher();
void updateCompletion(String text, AutoCompleteAddressInput dest) {
SearchService.suggestLocations(text,
LocationService.getCurrentLocation(), resultList -> {
if(resultList != null && resultList.size() > 0) {
result.removeAll();
completionUsed = true;
for(SearchService.SuggestionResult r : resultList) {
MultiButton mb = createEntry(FontImage.MATERIAL_PLACE,
r.getMainText(), r.getSecondaryText());
result.add(mb);
mb.addActionListener(e -> {
dest.setTextNoEvent(r.getFullText());
r.getLocation(l -> {
dest.setCurrentLocation(l);
dispatcher.fireActionEvent(e);
});
});
}
CompletionContainer
public class CompletionContainer {
private Container result;
private boolean completionUsed;
private final EventDispatcher dispatcher = new EventDispatcher();
void updateCompletion(String text, AutoCompleteAddressInput dest) {
SearchService.suggestLocations(text,
LocationService.getCurrentLocation(), resultList -> {
if(resultList != null && resultList.size() > 0) {
result.removeAll();
completionUsed = true;
for(SearchService.SuggestionResult r : resultList) {
MultiButton mb = createEntry(FontImage.MATERIAL_PLACE,
r.getMainText(), r.getSecondaryText());
result.add(mb);
mb.addActionListener(e -> {
dest.setTextNoEvent(r.getFullText());
r.getLocation(l -> {
dest.setCurrentLocation(l);
dispatcher.fireActionEvent(e);
});
});
}
CompletionContainer
public class CompletionContainer {
private Container result;
private boolean completionUsed;
private final EventDispatcher dispatcher = new EventDispatcher();
void updateCompletion(String text, AutoCompleteAddressInput dest) {
SearchService.suggestLocations(text,
LocationService.getCurrentLocation(), resultList -> {
if(resultList != null && resultList.size() > 0) {
result.removeAll();
completionUsed = true;
for(SearchService.SuggestionResult r : resultList) {
MultiButton mb = createEntry(FontImage.MATERIAL_PLACE,
r.getMainText(), r.getSecondaryText());
result.add(mb);
mb.addActionListener(e -> {
dest.setTextNoEvent(r.getFullText());
r.getLocation(l -> {
dest.setCurrentLocation(l);
dispatcher.fireActionEvent(e);
});
});
}
CompletionContainer
public class CompletionContainer {
private Container result;
private boolean completionUsed;
private final EventDispatcher dispatcher = new EventDispatcher();
void updateCompletion(String text, AutoCompleteAddressInput dest) {
SearchService.suggestLocations(text,
LocationService.getCurrentLocation(), resultList -> {
if(resultList != null && resultList.size() > 0) {
result.removeAll();
completionUsed = true;
for(SearchService.SuggestionResult r : resultList) {
MultiButton mb = createEntry(FontImage.MATERIAL_PLACE,
r.getMainText(), r.getSecondaryText());
result.add(mb);
mb.addActionListener(e -> {
dest.setTextNoEvent(r.getFullText());
r.getLocation(l -> {
dest.setCurrentLocation(l);
dispatcher.fireActionEvent(e);
});
});
}
CompletionContainer
result.animateLayout(150);
}
});
}
private MultiButton createEntry(char icon, String title) {
MultiButton b = new MultiButton(title);
b.setUIID("Container");
b.setUIIDLine1("WhereToButtonLine1");
b.setIconUIID("WhereToButtonIcon");
FontImage.setMaterialIcon(b, icon);
return b;
}
private MultiButton createEntry(char icon, String title, String subtitle) {
MultiButton b = new MultiButton(title);
b.setTextLine2(subtitle);
b.setUIID("Container");
b.setUIIDLine1("WhereToButtonLineNoBorder");
b.setUIIDLine2("WhereToButtonLine2");
b.setIconUIID("WhereToButtonIcon");
FontImage.setMaterialIcon(b, icon);
return b;
CompletionContainer
b.setUIIDLine2("WhereToButtonLine2");
b.setIconUIID("WhereToButtonIcon");
FontImage.setMaterialIcon(b, icon);
return b;
}
public void initCompletionBar() {
if(!completionUsed) {
return;
}
completionUsed = false;
result.removeAll();
initCompletionBarImpl();
}
private void initCompletionBarImpl() {
MultiButton addHome = createEntry(FontImage.MATERIAL_HOME,
"Add Home");
MultiButton addWork = createEntry(FontImage.MATERIAL_WORK,
"Add Work");
MultiButton savedPlaces = createEntry(
FontImage.MATERIAL_NAVIGATE_NEXT, "Saved Places");
savedPlaces.setUIIDLine1("WhereToButtonLineNoBorder");
savedPlaces.setEmblemUIID("WhereToButtonLineNoBorder");
savedPlaces.setEmblem(FontImage.createMaterial(
CompletionContainer
savedPlaces.setUIIDLine1("WhereToButtonLineNoBorder");
savedPlaces.setEmblemUIID("WhereToButtonLineNoBorder");
savedPlaces.setEmblem(FontImage.createMaterial(
FontImage.MATERIAL_NAVIGATE_NEXT,
savedPlaces.getIconComponent().getUnselectedStyle()));
Label whereSeparator = new Label("", "WhereSeparator");
whereSeparator.setShowEvenIfBlank(true);
result.addAll(addHome, addWork, savedPlaces, whereSeparator);
addHistoryToCompletionBar();
}
private void addHistoryToCompletionBar() {
MultiButton history1 = createEntry(FontImage.MATERIAL_HISTORY,
"Mikve Yisrael Str...");
result.add(history1);
}
public void showCompletionBar(Container parentLayer) {
result = new Container(BoxLayout.y());
initCompletionBarImpl();
CompletionContainer
private void addHistoryToCompletionBar() {
MultiButton history1 = createEntry(FontImage.MATERIAL_HISTORY,
"Mikve Yisrael Str...");
result.add(history1);
}
public void showCompletionBar(Container parentLayer) {
result = new Container(BoxLayout.y());
initCompletionBarImpl();
result.setUIID("Form");
result.setScrollableY(true);
result.setScrollVisible(false);
Container enclose = BorderLayout.center(result);
enclose.setY(getDisplayHeight());
enclose.setWidth(getDisplayWidth());
enclose.setHeight(result.getPreferredH());
parentLayer.add(CENTER, enclose);
parentLayer.animateLayout(200);
}
public void addCompletionListener(ActionListener<ActionEvent> a) {
dispatcher.addListener(a);
CompletionContainer
WhereToButtonLine2
© Codename One 2017 all rights reserved
WhereToButtonLine2
© Codename One 2017 all rights reserved
WhereToButtonLine2
© Codename One 2017 all rights reserved
WhereToButtonLine2
© Codename One 2017 all rights reserved
WhereToButtonLine2
© Codename One 2017 all rights reserved

More Related Content

PDF
Creating an Uber Clone - Part XX - Transcript.pdf
PDF
Creating an Uber Clone - Part XIX.pdf
PDF
Creating an Uber Clone - Part IX.pdf
PDF
Creating an Uber Clone - Part XIX - Transcript.pdf
PDF
Creating an Uber Clone - Part XXI.pdf
PDF
Creating an Uber Clone - Part XXX.pdf
PDF
Creating an Uber Clone - Part XXI - Transcript.pdf
PDF
Material Design and Backwards Compatibility
Creating an Uber Clone - Part XX - Transcript.pdf
Creating an Uber Clone - Part XIX.pdf
Creating an Uber Clone - Part IX.pdf
Creating an Uber Clone - Part XIX - Transcript.pdf
Creating an Uber Clone - Part XXI.pdf
Creating an Uber Clone - Part XXX.pdf
Creating an Uber Clone - Part XXI - Transcript.pdf
Material Design and Backwards Compatibility

More from ShaiAlmog1 (20)

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

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Assigned Numbers - 2025 - Bluetooth® Document
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.
Teaching material agriculture food technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Machine Learning_overview_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Chapter 3 Spatial Domain Image Processing.pdf

Creating an Uber Clone - Part XX.pdf

  • 1. Creating an Uber Clone - Part XX
  • 2. public class CompletionContainer { private Container result; private boolean completionUsed; private final EventDispatcher dispatcher = new EventDispatcher(); void updateCompletion(String text, AutoCompleteAddressInput dest) { SearchService.suggestLocations(text, LocationService.getCurrentLocation(), resultList -> { if(resultList != null && resultList.size() > 0) { result.removeAll(); completionUsed = true; for(SearchService.SuggestionResult r : resultList) { MultiButton mb = createEntry(FontImage.MATERIAL_PLACE, r.getMainText(), r.getSecondaryText()); result.add(mb); mb.addActionListener(e -> { dest.setTextNoEvent(r.getFullText()); r.getLocation(l -> { dest.setCurrentLocation(l); dispatcher.fireActionEvent(e); }); }); } CompletionContainer
  • 3. public class CompletionContainer { private Container result; private boolean completionUsed; private final EventDispatcher dispatcher = new EventDispatcher(); void updateCompletion(String text, AutoCompleteAddressInput dest) { SearchService.suggestLocations(text, LocationService.getCurrentLocation(), resultList -> { if(resultList != null && resultList.size() > 0) { result.removeAll(); completionUsed = true; for(SearchService.SuggestionResult r : resultList) { MultiButton mb = createEntry(FontImage.MATERIAL_PLACE, r.getMainText(), r.getSecondaryText()); result.add(mb); mb.addActionListener(e -> { dest.setTextNoEvent(r.getFullText()); r.getLocation(l -> { dest.setCurrentLocation(l); dispatcher.fireActionEvent(e); }); }); } CompletionContainer
  • 4. public class CompletionContainer { private Container result; private boolean completionUsed; private final EventDispatcher dispatcher = new EventDispatcher(); void updateCompletion(String text, AutoCompleteAddressInput dest) { SearchService.suggestLocations(text, LocationService.getCurrentLocation(), resultList -> { if(resultList != null && resultList.size() > 0) { result.removeAll(); completionUsed = true; for(SearchService.SuggestionResult r : resultList) { MultiButton mb = createEntry(FontImage.MATERIAL_PLACE, r.getMainText(), r.getSecondaryText()); result.add(mb); mb.addActionListener(e -> { dest.setTextNoEvent(r.getFullText()); r.getLocation(l -> { dest.setCurrentLocation(l); dispatcher.fireActionEvent(e); }); }); } CompletionContainer
  • 5. public class CompletionContainer { private Container result; private boolean completionUsed; private final EventDispatcher dispatcher = new EventDispatcher(); void updateCompletion(String text, AutoCompleteAddressInput dest) { SearchService.suggestLocations(text, LocationService.getCurrentLocation(), resultList -> { if(resultList != null && resultList.size() > 0) { result.removeAll(); completionUsed = true; for(SearchService.SuggestionResult r : resultList) { MultiButton mb = createEntry(FontImage.MATERIAL_PLACE, r.getMainText(), r.getSecondaryText()); result.add(mb); mb.addActionListener(e -> { dest.setTextNoEvent(r.getFullText()); r.getLocation(l -> { dest.setCurrentLocation(l); dispatcher.fireActionEvent(e); }); }); } CompletionContainer
  • 6. result.animateLayout(150); } }); } private MultiButton createEntry(char icon, String title) { MultiButton b = new MultiButton(title); b.setUIID("Container"); b.setUIIDLine1("WhereToButtonLine1"); b.setIconUIID("WhereToButtonIcon"); FontImage.setMaterialIcon(b, icon); return b; } private MultiButton createEntry(char icon, String title, String subtitle) { MultiButton b = new MultiButton(title); b.setTextLine2(subtitle); b.setUIID("Container"); b.setUIIDLine1("WhereToButtonLineNoBorder"); b.setUIIDLine2("WhereToButtonLine2"); b.setIconUIID("WhereToButtonIcon"); FontImage.setMaterialIcon(b, icon); return b; CompletionContainer
  • 7. b.setUIIDLine2("WhereToButtonLine2"); b.setIconUIID("WhereToButtonIcon"); FontImage.setMaterialIcon(b, icon); return b; } public void initCompletionBar() { if(!completionUsed) { return; } completionUsed = false; result.removeAll(); initCompletionBarImpl(); } private void initCompletionBarImpl() { MultiButton addHome = createEntry(FontImage.MATERIAL_HOME, "Add Home"); MultiButton addWork = createEntry(FontImage.MATERIAL_WORK, "Add Work"); MultiButton savedPlaces = createEntry( FontImage.MATERIAL_NAVIGATE_NEXT, "Saved Places"); savedPlaces.setUIIDLine1("WhereToButtonLineNoBorder"); savedPlaces.setEmblemUIID("WhereToButtonLineNoBorder"); savedPlaces.setEmblem(FontImage.createMaterial( CompletionContainer
  • 8. savedPlaces.setUIIDLine1("WhereToButtonLineNoBorder"); savedPlaces.setEmblemUIID("WhereToButtonLineNoBorder"); savedPlaces.setEmblem(FontImage.createMaterial( FontImage.MATERIAL_NAVIGATE_NEXT, savedPlaces.getIconComponent().getUnselectedStyle())); Label whereSeparator = new Label("", "WhereSeparator"); whereSeparator.setShowEvenIfBlank(true); result.addAll(addHome, addWork, savedPlaces, whereSeparator); addHistoryToCompletionBar(); } private void addHistoryToCompletionBar() { MultiButton history1 = createEntry(FontImage.MATERIAL_HISTORY, "Mikve Yisrael Str..."); result.add(history1); } public void showCompletionBar(Container parentLayer) { result = new Container(BoxLayout.y()); initCompletionBarImpl(); CompletionContainer
  • 9. private void addHistoryToCompletionBar() { MultiButton history1 = createEntry(FontImage.MATERIAL_HISTORY, "Mikve Yisrael Str..."); result.add(history1); } public void showCompletionBar(Container parentLayer) { result = new Container(BoxLayout.y()); initCompletionBarImpl(); result.setUIID("Form"); result.setScrollableY(true); result.setScrollVisible(false); Container enclose = BorderLayout.center(result); enclose.setY(getDisplayHeight()); enclose.setWidth(getDisplayWidth()); enclose.setHeight(result.getPreferredH()); parentLayer.add(CENTER, enclose); parentLayer.animateLayout(200); } public void addCompletionListener(ActionListener<ActionEvent> a) { dispatcher.addListener(a); CompletionContainer
  • 10. WhereToButtonLine2 © Codename One 2017 all rights reserved
  • 11. WhereToButtonLine2 © Codename One 2017 all rights reserved
  • 12. WhereToButtonLine2 © Codename One 2017 all rights reserved
  • 13. WhereToButtonLine2 © Codename One 2017 all rights reserved
  • 14. WhereToButtonLine2 © Codename One 2017 all rights reserved