SlideShare a Scribd company logo
1 of 37
Download to read offline
Android Wear CodeLab
GDG Firenze
Fabio Collini
Android Wear CodeLab – November 2015 – @fabioCollini 2
Ego slide
@fabioCollini
linkedin.com/in/fabiocollini
Folder Organizer
cosenonjaviste.it
nana bianca
Freapp
instal.com
Rain tomorrow?
Android Wear CodeLab – November 2015 – @fabioCollini 3
Agenda
1. Android Wear
2. Creazione nuovo progetto
3. Aggiunta librerie
4. Layout per smartwatch
5. Comunicazione con smartphone
6. Layout multi fragment
Android Wear CodeLab - November 2015 - @fabioCollini 4
Android Wear
1
Android Wear CodeLab – November 2015 – @fabioCollini 5
Android Wear
Notifiche
Watch faces
Wear apps
Android Wear CodeLab – November 2015 – @fabioCollini 6
Citymapper
Android Wear CodeLab – November 2015 – @fabioCollini 7
Android Wear CodeLab - November 2015 - @fabioCollini 8
2Creazione nuovo progetto
Android Wear CodeLab – November 2015 – @fabioCollini 9
Wizard creazione nuovo progetto
Android Wear CodeLab – November 2015 – @fabioCollini 10
Due moduli nel progetto
Android Wear CodeLab - November 2015 - @fabioCollini 11
3Aggiunta librerie
Android Wear CodeLab – November 2015 – @fabioCollini 12
Progetto su github
https://github.com/fabioCollini/AndroidWearCodeLab
Android Wear CodeLab – November 2015 – @fabioCollini 13
App smartphone
Android Wear CodeLab - November 2015 - @fabioCollini 14
4Layout per smartwatch
Android Wear CodeLab – November 2015 – @fabioCollini 15
WatchViewStub
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_main"
app:roundLayout="@layout/round_activity_main"
tools:context=".MainActivity"
tools:deviceIds="wear">
Android Wear CodeLab – November 2015 – @fabioCollini 16
WearableFrameLayout
<android.support.wearable.view.WearableFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_height="@dimen/watch_face_width"
android:layout_width="@dimen/watch_face_width"
android:layout_marginTop="@dimen/watch_face_margin_top"
app:layout_heightRound="@dimen/watch_face_circular_size"
app:layout_widthRound="@dimen/watch_face_circular_size"
app:layout_marginTopRound="@dimen/watch_face_circular_margin_top"
app:layout_gravityRound=“center_horizontal" />
</android.support.wearable.view.WearableFrameLayout>
Android Wear CodeLab – November 2015 – @fabioCollini 17
BoxInsetLayout
Gestisce il padding di un layout adattandolo a
smartwatch quadrati e rotondi
Il layout contenuto specifica quali lati gestire (per
esempio con app:layout_box=“all”)
Non deve contenere un padding specificato
Android Wear CodeLab – November 2015 – @fabioCollini 18
Layout risposta sondaggio
Android Wear CodeLab - November 2015 - @fabioCollini 19
5Comunicazione con
smartphone
Android Wear CodeLab – November 2015 – @fabioCollini 20
GoogleApiClient
DataApi
MessageApi
NodeApi
CapabilityApi
ChannelApi
Android Wear CodeLab – November 2015 – @fabioCollini 21
Teleport
Data Sync & Messaging Library for Android Wear
Android Wear CodeLab – November 2015 – @fabioCollini 22
TeleportClient
public class MobileActivity extends Activity {

private TeleportClient teleportClient;



@Override protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.my_layout);

teleportClient = new TeleportClient(this);

}



@Override protected void onStart() {

super.onStart();

teleportClient.connect();

}



@Override protected void onStop() {

super.onStop();

teleportClient.disconnect();

}
}
Android Wear CodeLab – November 2015 – @fabioCollini 23
ClickListener
Aggiungere il click listener sui due button che
mandano un messaggio usando teleportClient
Android Wear CodeLab – November 2015 – @fabioCollini 24
Service
public class MyService extends TeleportService {

private SurveyManager surveyManager;



@Override public void onCreate() {

super.onCreate();

surveyManager = new SurveyManager(this);

setOnGetMessageCallback(new MyOnGetMessageCallback());

}



private class MyOnGetMessageCallback extends OnGetMessageCallback {

@Override public void onCallback(String s) {
…
setOnGetMessageCallback(new MyOnGetMessageCallback());

}

}
}
Android Wear CodeLab – November 2015 – @fabioCollini 25
Mobile manifest
<service android:name=".MyService" android:enabled="true"
android:exported="true">

<intent-filter>

<action android:name=
"com.google.android.gms.wearable.BIND_LISTENER"/>

</intent-filter>
</service>
Android Wear CodeLab – November 2015 – @fabioCollini 26
Activity di conferma
Intent intent = new Intent(getActivity(),
ConfirmationActivity.class);
intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
ConfirmationActivity.SUCCESS_ANIMATION);
intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
getString(R.string.answer_sent));
startActivity(intent);
<activity android:name=
"android.support.wearable.activity.ConfirmationActivity" />
Android Wear CodeLab - November 2015 - @fabioCollini 27
6Layout multi fragment
Android Wear CodeLab – November 2015 – @fabioCollini 28
Activity -> Fragment
Spostare tutto il codice in una nuova classe
Creazione del layout in onCreateView usando
inflater.inflate(R.layout.answer, container, false);
Metodi protected -> public
this -> getActivity()
Android Wear CodeLab – November 2015 – @fabioCollini 29
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>

<FrameLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:id=“@+id/root"
android:layout_width="match_parent"

android:layout_height="match_parent">



<fragment

android:name="it.cosenonjaviste.mywearapp.AnswerFragment"

android:layout_width="match_parent"

android:layout_height=“match_parent"/>


</FrameLayout>
Android Wear CodeLab – November 2015 – @fabioCollini 30
GridViewPager & DotsPageIndicator
<FrameLayout
….
>
<android.support.wearable.view.GridViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.wearable.view.DotsPageIndicator
android:id="@+id/page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="10dp"/>
</FrameLayout>
Android Wear CodeLab – November 2015 – @fabioCollini 31
FragmentGridPagerAdapter
Tre metodi da implementare:
• getRowCount
• getColumnCount
• getFragment(int row, int column)
Android Wear CodeLab – November 2015 – @fabioCollini 32
Activity
GridViewPager pager =
(GridViewPager) findViewById(R.id.pager);
pager.setAdapter(new MyAdapter(getFragmentManager()));
DotsPageIndicator dotsPageIndicator =
(DotsPageIndicator) findViewById(R.id.page_indicator);
dotsPageIndicator.setPager(pager);
Android Wear CodeLab – November 2015 – @fabioCollini 33
survey_detail.xml
Android Wear CodeLab – November 2015 – @fabioCollini 34
Survey detail fragment
onCreate
aggiunge un listener sul sync per aggiornare la UI
onStart
invia un messaggio di start allo smartphone
onStop
invia un messaggio di stop allo smartphone
Android Wear CodeLab – November 2015 – @fabioCollini 35
Service su mobile
Messaggio di start
surveyManager.addValueEventListener per
eseguire un sync ogni volta che cambiano i dati
su Firebase usando
syncString("survey", survey.toJson());
Messaggio di stop
surveyManager.removeEventListener
Android Wear CodeLab – November 2015 – @fabioCollini 36
Sync su wear
Prendere la stringa con il json dal dataMap
Eseguire il parsing usando Survey.parse
Aggiornare la ui con i dati
Android Wear CodeLab – November 2015 – @fabioCollini 37
Thanks for your attention!
androidavanzato.it
Questions?

More Related Content

Viewers also liked

Introduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaIntroduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaFabio Collini
 
Data Binding in Action using MVVM pattern
Data Binding in Action using MVVM patternData Binding in Action using MVVM pattern
Data Binding in Action using MVVM patternFabio Collini
 
Clean android code - Droidcon Italiy 2014
Clean android code - Droidcon Italiy 2014Clean android code - Droidcon Italiy 2014
Clean android code - Droidcon Italiy 2014Fabio Collini
 
Android Widget @ whymca 2011
Android Widget @ whymca 2011Android Widget @ whymca 2011
Android Widget @ whymca 2011Fabio Collini
 
Librerie su Android: come non reinventare la ruota @ whymca 2012
Librerie su Android: come non reinventare la ruota @ whymca 2012 Librerie su Android: come non reinventare la ruota @ whymca 2012
Librerie su Android: come non reinventare la ruota @ whymca 2012 Fabio Collini
 
Model-View-ViewModel and RxJava
Model-View-ViewModel and RxJavaModel-View-ViewModel and RxJava
Model-View-ViewModel and RxJavaFlorina Muntenescu
 
Community Contribution Experience
Community Contribution ExperienceCommunity Contribution Experience
Community Contribution ExperienceAdil Mughal
 
Windows 7 For Geeks
Windows 7 For GeeksWindows 7 For Geeks
Windows 7 For GeeksAdil Mughal
 
DevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetDevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetAdil Mughal
 
What's New in Visual Studio 2010
What's New in Visual Studio 2010What's New in Visual Studio 2010
What's New in Visual Studio 2010Adil Mughal
 
Code Sharing Between Windows Phone/Store Apps
Code Sharing Between Windows Phone/Store AppsCode Sharing Between Windows Phone/Store Apps
Code Sharing Between Windows Phone/Store AppsAdil Mughal
 
Write cleaner, maintainable, and testable code in Android with MVVM
Write cleaner, maintainable, and testable code in Android with MVVMWrite cleaner, maintainable, and testable code in Android with MVVM
Write cleaner, maintainable, and testable code in Android with MVVMAdil Mughal
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECAdil Mughal
 
MVVM with DataBinding on android
MVVM with DataBinding on androidMVVM with DataBinding on android
MVVM with DataBinding on androidRodrigo Bressan
 
Mockito, Robobinding
Mockito, RobobindingMockito, Robobinding
Mockito, RobobindingKyungHo Jung
 
Rx Creating Operators, observeOn, subscribeOn
Rx Creating Operators, observeOn, subscribeOnRx Creating Operators, observeOn, subscribeOn
Rx Creating Operators, observeOn, subscribeOnKyungHo Jung
 
May 05 test_code_states
May 05 test_code_statesMay 05 test_code_states
May 05 test_code_statesKyungHo Jung
 
Kotlin 사용기
Kotlin 사용기Kotlin 사용기
Kotlin 사용기KyungHo Jung
 
Quality Assurance in SDLC
Quality Assurance in SDLCQuality Assurance in SDLC
Quality Assurance in SDLCAdil Mughal
 

Viewers also liked (20)

Introduction to Retrofit and RxJava
Introduction to Retrofit and RxJavaIntroduction to Retrofit and RxJava
Introduction to Retrofit and RxJava
 
Data Binding in Action using MVVM pattern
Data Binding in Action using MVVM patternData Binding in Action using MVVM pattern
Data Binding in Action using MVVM pattern
 
Clean android code - Droidcon Italiy 2014
Clean android code - Droidcon Italiy 2014Clean android code - Droidcon Italiy 2014
Clean android code - Droidcon Italiy 2014
 
Android Widget @ whymca 2011
Android Widget @ whymca 2011Android Widget @ whymca 2011
Android Widget @ whymca 2011
 
Librerie su Android: come non reinventare la ruota @ whymca 2012
Librerie su Android: come non reinventare la ruota @ whymca 2012 Librerie su Android: come non reinventare la ruota @ whymca 2012
Librerie su Android: come non reinventare la ruota @ whymca 2012
 
Model-View-ViewModel and RxJava
Model-View-ViewModel and RxJavaModel-View-ViewModel and RxJava
Model-View-ViewModel and RxJava
 
Community Contribution Experience
Community Contribution ExperienceCommunity Contribution Experience
Community Contribution Experience
 
Windows 7 For Geeks
Windows 7 For GeeksWindows 7 For Geeks
Windows 7 For Geeks
 
DevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetDevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp Net
 
What's New in Visual Studio 2010
What's New in Visual Studio 2010What's New in Visual Studio 2010
What's New in Visual Studio 2010
 
Code Sharing Between Windows Phone/Store Apps
Code Sharing Between Windows Phone/Store AppsCode Sharing Between Windows Phone/Store Apps
Code Sharing Between Windows Phone/Store Apps
 
Write cleaner, maintainable, and testable code in Android with MVVM
Write cleaner, maintainable, and testable code in Android with MVVMWrite cleaner, maintainable, and testable code in Android with MVVM
Write cleaner, maintainable, and testable code in Android with MVVM
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HEC
 
MVVM with DataBinding on android
MVVM with DataBinding on androidMVVM with DataBinding on android
MVVM with DataBinding on android
 
Mockito, Robobinding
Mockito, RobobindingMockito, Robobinding
Mockito, Robobinding
 
Rx Creating Operators, observeOn, subscribeOn
Rx Creating Operators, observeOn, subscribeOnRx Creating Operators, observeOn, subscribeOn
Rx Creating Operators, observeOn, subscribeOn
 
May 05 test_code_states
May 05 test_code_statesMay 05 test_code_states
May 05 test_code_states
 
Kotlin 사용기
Kotlin 사용기Kotlin 사용기
Kotlin 사용기
 
Android MVVM TDD
Android MVVM TDDAndroid MVVM TDD
Android MVVM TDD
 
Quality Assurance in SDLC
Quality Assurance in SDLCQuality Assurance in SDLC
Quality Assurance in SDLC
 

Similar to Android Wear CodeLab - GDG Firenze

Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...Codemotion Tel Aviv
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxNgLQun
 
Augmented Reality Application Tutorial for Education 1
Augmented  Reality Application Tutorial for Education 1Augmented  Reality Application Tutorial for Education 1
Augmented Reality Application Tutorial for Education 1Isidro Navarro
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkImam Raza
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMrbl002
 
Modern Web Applications with Sightly
Modern Web Applications with SightlyModern Web Applications with Sightly
Modern Web Applications with SightlyRadu Cotescu
 
GDG Oslo: Hidden Android features
GDG Oslo: Hidden Android featuresGDG Oslo: Hidden Android features
GDG Oslo: Hidden Android featuresKonstantin Loginov
 
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...Codemotion
 
Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Hassan Abid
 
Introduzione a React Native - Facebook Developer Circle Rome
Introduzione a React Native - Facebook Developer Circle RomeIntroduzione a React Native - Facebook Developer Circle Rome
Introduzione a React Native - Facebook Developer Circle RomeMatteo Manchi
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentJustin James
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...Gavin Pickin
 
Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Neal Sanche
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicFioriela Bego
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicCommit Software Sh.p.k.
 
Android Jetpack - What's new
Android Jetpack - What's newAndroid Jetpack - What's new
Android Jetpack - What's newAhmad Arif Faizin
 
Google IO - Five months later
Google IO - Five months laterGoogle IO - Five months later
Google IO - Five months laterMatteo Bonifazi
 

Similar to Android Wear CodeLab - GDG Firenze (20)

Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...
Loopback: An Easy and Robust Mobile Backend - Michael Hantler & Aviv Callande...
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
 
Android development beginners faq
Android development  beginners faqAndroid development  beginners faq
Android development beginners faq
 
Augmented Reality Application Tutorial for Education 1
Augmented  Reality Application Tutorial for Education 1Augmented  Reality Application Tutorial for Education 1
Augmented Reality Application Tutorial for Education 1
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEM
 
Modern Web Applications with Sightly
Modern Web Applications with SightlyModern Web Applications with Sightly
Modern Web Applications with Sightly
 
GDG Oslo: Hidden Android features
GDG Oslo: Hidden Android featuresGDG Oslo: Hidden Android features
GDG Oslo: Hidden Android features
 
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
 
Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018Recap of Android Dev Summit 2018
Recap of Android Dev Summit 2018
 
Introduzione a React Native - Facebook Developer Circle Rome
Introduzione a React Native - Facebook Developer Circle RomeIntroduzione a React Native - Facebook Developer Circle Rome
Introduzione a React Native - Facebook Developer Circle Rome
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
 
Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && Ionic
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && Ionic
 
Android Jetpack - What's new
Android Jetpack - What's newAndroid Jetpack - What's new
Android Jetpack - What's new
 
Ionic 2 - O que mudou?
Ionic 2 - O que mudou?Ionic 2 - O que mudou?
Ionic 2 - O que mudou?
 
Google IO - Five months later
Google IO - Five months laterGoogle IO - Five months later
Google IO - Five months later
 

More from Fabio Collini

Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose worldFabio Collini
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized projectFabio Collini
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutinesFabio Collini
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confFabio Collini
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmFabio Collini
 
Using Dagger in a Clean Architecture project
Using Dagger in a Clean Architecture projectUsing Dagger in a Clean Architecture project
Using Dagger in a Clean Architecture projectFabio Collini
 
Solid principles in practice the clean architecture - Droidcon Italy
Solid principles in practice the clean architecture - Droidcon ItalySolid principles in practice the clean architecture - Droidcon Italy
Solid principles in practice the clean architecture - Droidcon ItalyFabio Collini
 
SOLID principles in practice: the Clean Architecture - Devfest Emila Romagna
SOLID principles in practice: the Clean Architecture - Devfest Emila RomagnaSOLID principles in practice: the Clean Architecture - Devfest Emila Romagna
SOLID principles in practice: the Clean Architecture - Devfest Emila RomagnaFabio Collini
 
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureSOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureFabio Collini
 
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinFabio Collini
 
Recap Google I/O 2018
Recap Google I/O 2018Recap Google I/O 2018
Recap Google I/O 2018Fabio Collini
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFabio Collini
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKFabio Collini
 
Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Fabio Collini
 
Testing Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaTesting Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaFabio Collini
 

More from Fabio Collini (17)

Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized project
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community conf
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere Stockholm
 
Using Dagger in a Clean Architecture project
Using Dagger in a Clean Architecture projectUsing Dagger in a Clean Architecture project
Using Dagger in a Clean Architecture project
 
Solid principles in practice the clean architecture - Droidcon Italy
Solid principles in practice the clean architecture - Droidcon ItalySolid principles in practice the clean architecture - Droidcon Italy
Solid principles in practice the clean architecture - Droidcon Italy
 
SOLID principles in practice: the Clean Architecture - Devfest Emila Romagna
SOLID principles in practice: the Clean Architecture - Devfest Emila RomagnaSOLID principles in practice: the Clean Architecture - Devfest Emila Romagna
SOLID principles in practice: the Clean Architecture - Devfest Emila Romagna
 
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureSOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean Architecture
 
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
 
Recap Google I/O 2018
Recap Google I/O 2018Recap Google I/O 2018
Recap Google I/O 2018
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+k
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UK
 
Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2Intro to Retrofit 2 and RxJava2
Intro to Retrofit 2 and RxJava2
 
Testing Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaTesting Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJava
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

Android Wear CodeLab - GDG Firenze

  • 1. Android Wear CodeLab GDG Firenze Fabio Collini
  • 2. Android Wear CodeLab – November 2015 – @fabioCollini 2 Ego slide @fabioCollini linkedin.com/in/fabiocollini Folder Organizer cosenonjaviste.it nana bianca Freapp instal.com Rain tomorrow?
  • 3. Android Wear CodeLab – November 2015 – @fabioCollini 3 Agenda 1. Android Wear 2. Creazione nuovo progetto 3. Aggiunta librerie 4. Layout per smartwatch 5. Comunicazione con smartphone 6. Layout multi fragment
  • 4. Android Wear CodeLab - November 2015 - @fabioCollini 4 Android Wear 1
  • 5. Android Wear CodeLab – November 2015 – @fabioCollini 5 Android Wear Notifiche Watch faces Wear apps
  • 6. Android Wear CodeLab – November 2015 – @fabioCollini 6 Citymapper
  • 7. Android Wear CodeLab – November 2015 – @fabioCollini 7
  • 8. Android Wear CodeLab - November 2015 - @fabioCollini 8 2Creazione nuovo progetto
  • 9. Android Wear CodeLab – November 2015 – @fabioCollini 9 Wizard creazione nuovo progetto
  • 10. Android Wear CodeLab – November 2015 – @fabioCollini 10 Due moduli nel progetto
  • 11. Android Wear CodeLab - November 2015 - @fabioCollini 11 3Aggiunta librerie
  • 12. Android Wear CodeLab – November 2015 – @fabioCollini 12 Progetto su github https://github.com/fabioCollini/AndroidWearCodeLab
  • 13. Android Wear CodeLab – November 2015 – @fabioCollini 13 App smartphone
  • 14. Android Wear CodeLab - November 2015 - @fabioCollini 14 4Layout per smartwatch
  • 15. Android Wear CodeLab – November 2015 – @fabioCollini 15 WatchViewStub <?xml version="1.0" encoding="utf-8"?> <android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/watch_view_stub" android:layout_width="match_parent" android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_main" app:roundLayout="@layout/round_activity_main" tools:context=".MainActivity" tools:deviceIds="wear">
  • 16. Android Wear CodeLab – November 2015 – @fabioCollini 16 WearableFrameLayout <android.support.wearable.view.WearableFrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_height="@dimen/watch_face_width" android:layout_width="@dimen/watch_face_width" android:layout_marginTop="@dimen/watch_face_margin_top" app:layout_heightRound="@dimen/watch_face_circular_size" app:layout_widthRound="@dimen/watch_face_circular_size" app:layout_marginTopRound="@dimen/watch_face_circular_margin_top" app:layout_gravityRound=“center_horizontal" /> </android.support.wearable.view.WearableFrameLayout>
  • 17. Android Wear CodeLab – November 2015 – @fabioCollini 17 BoxInsetLayout Gestisce il padding di un layout adattandolo a smartwatch quadrati e rotondi Il layout contenuto specifica quali lati gestire (per esempio con app:layout_box=“all”) Non deve contenere un padding specificato
  • 18. Android Wear CodeLab – November 2015 – @fabioCollini 18 Layout risposta sondaggio
  • 19. Android Wear CodeLab - November 2015 - @fabioCollini 19 5Comunicazione con smartphone
  • 20. Android Wear CodeLab – November 2015 – @fabioCollini 20 GoogleApiClient DataApi MessageApi NodeApi CapabilityApi ChannelApi
  • 21. Android Wear CodeLab – November 2015 – @fabioCollini 21 Teleport Data Sync & Messaging Library for Android Wear
  • 22. Android Wear CodeLab – November 2015 – @fabioCollini 22 TeleportClient public class MobileActivity extends Activity {
 private TeleportClient teleportClient;
 
 @Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.my_layout);
 teleportClient = new TeleportClient(this);
 }
 
 @Override protected void onStart() {
 super.onStart();
 teleportClient.connect();
 }
 
 @Override protected void onStop() {
 super.onStop();
 teleportClient.disconnect();
 } }
  • 23. Android Wear CodeLab – November 2015 – @fabioCollini 23 ClickListener Aggiungere il click listener sui due button che mandano un messaggio usando teleportClient
  • 24. Android Wear CodeLab – November 2015 – @fabioCollini 24 Service public class MyService extends TeleportService {
 private SurveyManager surveyManager;
 
 @Override public void onCreate() {
 super.onCreate();
 surveyManager = new SurveyManager(this);
 setOnGetMessageCallback(new MyOnGetMessageCallback());
 }
 
 private class MyOnGetMessageCallback extends OnGetMessageCallback {
 @Override public void onCallback(String s) { … setOnGetMessageCallback(new MyOnGetMessageCallback());
 }
 } }
  • 25. Android Wear CodeLab – November 2015 – @fabioCollini 25 Mobile manifest <service android:name=".MyService" android:enabled="true" android:exported="true">
 <intent-filter>
 <action android:name= "com.google.android.gms.wearable.BIND_LISTENER"/>
 </intent-filter> </service>
  • 26. Android Wear CodeLab – November 2015 – @fabioCollini 26 Activity di conferma Intent intent = new Intent(getActivity(), ConfirmationActivity.class); intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.SUCCESS_ANIMATION); intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE, getString(R.string.answer_sent)); startActivity(intent); <activity android:name= "android.support.wearable.activity.ConfirmationActivity" />
  • 27. Android Wear CodeLab - November 2015 - @fabioCollini 27 6Layout multi fragment
  • 28. Android Wear CodeLab – November 2015 – @fabioCollini 28 Activity -> Fragment Spostare tutto il codice in una nuova classe Creazione del layout in onCreateView usando inflater.inflate(R.layout.answer, container, false); Metodi protected -> public this -> getActivity()
  • 29. Android Wear CodeLab – November 2015 – @fabioCollini 29 activity_main.xml <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id=“@+id/root" android:layout_width="match_parent"
 android:layout_height="match_parent">
 
 <fragment
 android:name="it.cosenonjaviste.mywearapp.AnswerFragment"
 android:layout_width="match_parent"
 android:layout_height=“match_parent"/> 
 </FrameLayout>
  • 30. Android Wear CodeLab – November 2015 – @fabioCollini 30 GridViewPager & DotsPageIndicator <FrameLayout …. > <android.support.wearable.view.GridViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent"/> <android.support.wearable.view.DotsPageIndicator android:id="@+id/page_indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" android:layout_marginBottom="10dp"/> </FrameLayout>
  • 31. Android Wear CodeLab – November 2015 – @fabioCollini 31 FragmentGridPagerAdapter Tre metodi da implementare: • getRowCount • getColumnCount • getFragment(int row, int column)
  • 32. Android Wear CodeLab – November 2015 – @fabioCollini 32 Activity GridViewPager pager = (GridViewPager) findViewById(R.id.pager); pager.setAdapter(new MyAdapter(getFragmentManager())); DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager);
  • 33. Android Wear CodeLab – November 2015 – @fabioCollini 33 survey_detail.xml
  • 34. Android Wear CodeLab – November 2015 – @fabioCollini 34 Survey detail fragment onCreate aggiunge un listener sul sync per aggiornare la UI onStart invia un messaggio di start allo smartphone onStop invia un messaggio di stop allo smartphone
  • 35. Android Wear CodeLab – November 2015 – @fabioCollini 35 Service su mobile Messaggio di start surveyManager.addValueEventListener per eseguire un sync ogni volta che cambiano i dati su Firebase usando syncString("survey", survey.toJson()); Messaggio di stop surveyManager.removeEventListener
  • 36. Android Wear CodeLab – November 2015 – @fabioCollini 36 Sync su wear Prendere la stringa con il json dal dataMap Eseguire il parsing usando Survey.parse Aggiornare la ui con i dati
  • 37. Android Wear CodeLab – November 2015 – @fabioCollini 37 Thanks for your attention! androidavanzato.it Questions?