Enviar pesquisa
Carregar
Retrolambda+bolts
•
0 gostou
•
269 visualizações
Tom Sun
Seguir
Language: Traditional Chinese Bolts-Android & RetroLambda introduction
Leia menos
Leia mais
Engenharia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 25
Baixar agora
Baixar para ler offline
Recomendados
JavaFX8 TestFX - CDI
JavaFX8 TestFX - CDI
Sven Ruppert
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
chbornet
中華電信 教育訓練
中華電信 教育訓練
謝 宗穎
Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"
Fwdays
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
Fwdays
How to create an Angular builder
How to create an Angular builder
Maurizio Vitale
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
謝 宗穎
Recomendados
JavaFX8 TestFX - CDI
JavaFX8 TestFX - CDI
Sven Ruppert
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
chbornet
中華電信 教育訓練
中華電信 教育訓練
謝 宗穎
Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"
Fwdays
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
Fwdays
How to create an Angular builder
How to create an Angular builder
Maurizio Vitale
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
謝 宗穎
Eclipse Mars News @JUG HH
Eclipse Mars News @JUG HH
simonscholz
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
Виталий Редько "React + Redux: performance & scalability"
Виталий Редько "React + Redux: performance & scalability"
Fwdays
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Fwdays
Супер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOS
SQALab
vienna.js - Automatic testing of (RESTful) API documentation
vienna.js - Automatic testing of (RESTful) API documentation
Rouven Weßling
Continuous Integration for your Android projects
Continuous Integration for your Android projects
Sergii Zhuk
Rest, sockets em golang
Rest, sockets em golang
jefferson Otoni Lima
Graphql usage
Graphql usage
Valentin Buryakov
java8-patterns
java8-patterns
Justin Lin
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
Introducing spring
Introducing spring
Ernesto Hernández Rodríguez
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Florent BENOIT
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Chen-en Lu
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
Ortus Solutions, Corp
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
Yao Nien Chung
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
Annie Huang
Testing in go
Testing in go
Eduardo Felipe Ewert Bonet
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
Schalk Cronjé
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
Mais conteúdo relacionado
Mais procurados
Eclipse Mars News @JUG HH
Eclipse Mars News @JUG HH
simonscholz
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
Виталий Редько "React + Redux: performance & scalability"
Виталий Редько "React + Redux: performance & scalability"
Fwdays
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Fwdays
Супер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOS
SQALab
vienna.js - Automatic testing of (RESTful) API documentation
vienna.js - Automatic testing of (RESTful) API documentation
Rouven Weßling
Continuous Integration for your Android projects
Continuous Integration for your Android projects
Sergii Zhuk
Rest, sockets em golang
Rest, sockets em golang
jefferson Otoni Lima
Graphql usage
Graphql usage
Valentin Buryakov
java8-patterns
java8-patterns
Justin Lin
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
Introducing spring
Introducing spring
Ernesto Hernández Rodríguez
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Florent BENOIT
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Chen-en Lu
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
Ortus Solutions, Corp
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
Yao Nien Chung
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
Annie Huang
Testing in go
Testing in go
Eduardo Felipe Ewert Bonet
Mais procurados
(20)
Eclipse Mars News @JUG HH
Eclipse Mars News @JUG HH
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Виталий Редько "React + Redux: performance & scalability"
Виталий Редько "React + Redux: performance & scalability"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
Супер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOS
vienna.js - Automatic testing of (RESTful) API documentation
vienna.js - Automatic testing of (RESTful) API documentation
Continuous Integration for your Android projects
Continuous Integration for your Android projects
Rest, sockets em golang
Rest, sockets em golang
Graphql usage
Graphql usage
java8-patterns
java8-patterns
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
Introducing spring
Introducing spring
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
Testing in go
Testing in go
Semelhante a Retrolambda+bolts
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
Schalk Cronjé
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
Schalk Cronjé
HTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
testing.pdf
testing.pdf
NuttavutThongjor1
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Java User Group Latvia
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
Schalk Cronjé
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
Loiane Groner
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
Enter the gradle
Enter the gradle
Parameswari Ettiappan
Gradle in 45min
Gradle in 45min
Schalk Cronjé
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
simonscholz
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios - Medianet Software
Ernesto Hernández Rodríguez
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Roman Kirillov
How to Build & Use OpenCL on OpenCV & Android NDK
How to Build & Use OpenCL on OpenCV & Android NDK
Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院)
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Ortus Solutions, Corp
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
What's New in Groovy 1.6?
What's New in Groovy 1.6?
Guillaume Laforge
Patterns Are Good For Managers
Patterns Are Good For Managers
AgileThought
Semelhante a Retrolambda+bolts
(20)
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
HTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
testing.pdf
testing.pdf
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Enter the gradle
Enter the gradle
Gradle in 45min
Gradle in 45min
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios - Medianet Software
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
How to Build & Use OpenCL on OpenCV & Android NDK
How to Build & Use OpenCL on OpenCV & Android NDK
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
What's New in Groovy 1.6?
What's New in Groovy 1.6?
Patterns Are Good For Managers
Patterns Are Good For Managers
Mais de Tom Sun
Pioc
Pioc
Tom Sun
Cloud radio 閃電秀
Cloud radio 閃電秀
Tom Sun
健康報告:德國飲食
健康報告:德國飲食
Tom Sun
Linux usb2ether
Linux usb2ether
Tom Sun
iOs app 101
iOs app 101
Tom Sun
Whos Fault
Whos Fault
Tom Sun
小巫婆麗特拉
小巫婆麗特拉
Tom Sun
Serial Pnp
Serial Pnp
Tom Sun
Mais de Tom Sun
(8)
Pioc
Pioc
Cloud radio 閃電秀
Cloud radio 閃電秀
健康報告:德國飲食
健康報告:德國飲食
Linux usb2ether
Linux usb2ether
iOs app 101
iOs app 101
Whos Fault
Whos Fault
小巫婆麗特拉
小巫婆麗特拉
Serial Pnp
Serial Pnp
Último
University management System project report..pdf
University management System project report..pdf
Kamal Acharya
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
Call Girls in Nagpur High Profile Call Girls
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Call Girls in Nagpur High Profile
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Christo Ananth
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Call Girls in Nagpur High Profile
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
simmis5
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
ranjana rawat
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
roncy bisnoi
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
M Maged Hegazy, LLM, MBA, CCP, P3O
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
JiananWang21
result management system report for college project
result management system report for college project
Tonystark477637
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
SUHANI PANDEY
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
bhaskargani46
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
fenichawla
Thermal Engineering Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
DineshKumar4165
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
rknatarajan
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
Último
(20)
University management System project report..pdf
University management System project report..pdf
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
result management system report for college project
result management system report for college project
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
Thermal Engineering Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
Retrolambda+bolts
1.
Bolts + RetroLambda 2015.11.26
2.
• Bolts-Android • Design
API Based On Bolts • Retrolabmda • Refactor
3.
Why use ? •
spec.
4.
member func() { Serialize
Asynchronous Tasks callback { callback { callback{ } then { then { then { } } } } member func() { } } }
5.
• Bolts-Android • Design
API Based On Bolts • Retrolabmda • Refactor
6.
Example show dialog press “YES” button
Cancel Do something NO YES
7.
Example 1/4 public class
RunnableCB implements Runnable { public void run() { this.run(); } }
8.
private AlertDialog simpleAlertDialog(String
message, final RunnableCB cb) { if (cb == null) { final RunnableCB emptyCallback= new RunnableCB() { public void run() { } }; return buildDialog(message, "OK", emptyCallback); } else { return buildDialog(message, "OK", cb); } } Example 2/4
9.
private AlertDialog buildDialog(String
message, String cb1Option, final RunnableCB cb1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message); builder.setPositiveButton(cb1Option, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); cb1.run(); } }); return builder.create(); } Example 3/4
10.
final RunnableCB cbSwitchOff
= new RunnableCB() { public void run() { ((CompoundButton) bleSwitch).setChecked(false); } }; String str = getResources().getString(R.string.no_ble_device_available); simpleAlertDialog(str, cbSwitchOff).show(); Example 4/4
11.
Refactor with Bolts public
class Dialog { static Task<Integer> dlg(String msg, String opt1, String opt2) { final Task<Integer>.TaskCompletionSource tcs = Task.create(); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(msg); if (opt1 != null && !opt1.isEmpty()) { builder.setPositiveButton(opt1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tcs.setResult(0); } }); } if (opt2 != null && !opt2.isEmpty()) { builder.setPositiveButton(opt2, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tcs.setResult(1); } }); } AlertDialog d = builder.create(); d.show(); return tcs.getTask(); } }
12.
String str =
getResources().getString(R.string.no_ble_device_available); mDialog.show(str, "OK", null).continueWith(new Continuation<Integer, Void>() { @Override public Void then(Task<Integer> task) throws Exception { ((CompoundButton) bleSwitch).setChecked(false); return null; } }); Calling API we made RunnableCB
13.
, they !! (
Java)
14.
• Bolts-Android • Design
API Based On Bolts • Retrolabmda • Refactor
15.
What’s Retrolambda • Back
port Java8 to Java 7, 6, 5 • Syntax Sugar ( ) • Good introduction : Ingram Chen http:// ingramchen.io/blog/2014/10/retromlambda.html
16.
Retrolambda Limitation • Does
not back port Java 8 APIs https://docs.oracle.com/javase/8/docs/api/java/ util/function/package-summary.html
17.
gradle • • https://github.com/evant/gradle-retrolambda
18.
// defined in
the SDK interface OnClickListener { public void onClick(View v); } // your code mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something here } }); syntax sugar 1/2
19.
mButton.setOnClickListener((View v) ->
{ // do something here }); syntax sugar 2/2
20.
• Bolts-Android • Design
API Based On Bolts • Code Example • Retrolabmda • Refactor
21.
public class Dialog
{ static Task<Integer> dlg(String msg, String opt1, String opt2) { final Task<Integer>.TaskCompletionSource tcs = Task.create(); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(msg); if (opt1 != null && !opt1.isEmpty()) { builder.setPositiveButton(opt1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tcs.setResult(0); } }); } if (opt2 != null && !opt2.isEmpty()) { builder.setPositiveButton(opt2, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tcs.setResult(1); } }); } AlertDialog d = builder.create(); d.show(); return tcs.getTask(); } } -> ->
22.
String str =
getResources().getString(R.string.no_ble_device_available); mDialog.show(str, "OK", null).continueWith(new Continuation<Integer, Void>() { @Override public Void then(Task<Integer> task) throws Exception { ((CompoundButton) bleSwitch).setChecked(false); return null; } }); ->
23.
public Task<Integer> show(String
msg, String opt1, String opt2) { final Task.TaskCompletionSource tcs = Task.create(); final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(msg); if (opt1 != null && !opt1.isEmpty()) { builder.setPositiveButton(opt1, (DialogInterface dialog, int which) -> { tcs.setResult(0); }); } if (opt2 != null && !opt2.isEmpty()) { builder.setNegativeButton(opt2, (DialogInterface dialog, int which) -> { tcs.setResult(1); }); } AlertDialog d = builder.create(); d.show(); return tcs.getTask(); } Result 1/2
24.
mDialog.show1(R.string.no_ble_device_available).continueWith(task -> { ((CompoundButton)
bleSwitch).setChecked(false); gotoScanPage(); return null; }); Result 2/2
Baixar agora