Submit Search
Upload
Droidcon ES '16 - How to fail going offline
•
3 likes
•
654 views
Javier de Pedro López
Follow
Architecture proposal to work offline using mainly android components and a single dataflow
Read less
Read more
Software
Report
Share
Report
Share
1 of 48
Download now
Download to read offline
Recommended
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
Yao Nien Chung
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Iakiv Kramarenko
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybara
Iakiv Kramarenko
軟體測試是在測試什麼?
軟體測試是在測試什麼?
Yao Nien Chung
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
Iakiv Kramarenko
KISS Automation.py
KISS Automation.py
Iakiv Kramarenko
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
Easy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
Iakiv Kramarenko
Recommended
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
Yao Nien Chung
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Iakiv Kramarenko
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybara
Iakiv Kramarenko
軟體測試是在測試什麼?
軟體測試是在測試什麼?
Yao Nien Chung
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
Iakiv Kramarenko
KISS Automation.py
KISS Automation.py
Iakiv Kramarenko
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
Easy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
Iakiv Kramarenko
Unit Testing for Great Justice
Unit Testing for Great Justice
Domenic Denicola
Dependency Injection
Dependency Injection
ColdFusionConference
Bowtie: Interactive Dashboards
Bowtie: Interactive Dashboards
Jacques Kvam
AngularJS Unit Test
AngularJS Unit Test
Chiew Carol
Testing in AngularJS
Testing in AngularJS
Peter Drinnan
Easy automation.py
Easy automation.py
Iakiv Kramarenko
It's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring Boot
VMware Tanzu
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
Summer Lu
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
Iakiv Kramarenko
Codeception presentation
Codeception presentation
Andrei Burian
Java Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to Miss
Andres Almiray
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
Dougal Campbell
learning react
learning react
Eueung Mulyana
Your code are my tests
Your code are my tests
Michelangelo van Dam
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Iakiv Kramarenko
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
johnnygroundwork
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
cpsitgmbh
The Screenplay Pattern: Better Interactions for Better Automation
The Screenplay Pattern: Better Interactions for Better Automation
Applitools
Getting Started with Maven and Cucumber in Eclipse
Getting Started with Maven and Cucumber in Eclipse
Tom Arend
World-Class Testing Development Pipeline for Android
World-Class Testing Development Pipeline for Android
Pedro Vicente Gómez Sánchez
Profile.e (yuki sato)0529
Profile.e (yuki sato)0529
Sato Yuki
More Related Content
What's hot
Unit Testing for Great Justice
Unit Testing for Great Justice
Domenic Denicola
Dependency Injection
Dependency Injection
ColdFusionConference
Bowtie: Interactive Dashboards
Bowtie: Interactive Dashboards
Jacques Kvam
AngularJS Unit Test
AngularJS Unit Test
Chiew Carol
Testing in AngularJS
Testing in AngularJS
Peter Drinnan
Easy automation.py
Easy automation.py
Iakiv Kramarenko
It's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring Boot
VMware Tanzu
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
Summer Lu
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
Iakiv Kramarenko
Codeception presentation
Codeception presentation
Andrei Burian
Java Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to Miss
Andres Almiray
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
Dougal Campbell
learning react
learning react
Eueung Mulyana
Your code are my tests
Your code are my tests
Michelangelo van Dam
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Iakiv Kramarenko
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
johnnygroundwork
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
cpsitgmbh
The Screenplay Pattern: Better Interactions for Better Automation
The Screenplay Pattern: Better Interactions for Better Automation
Applitools
Getting Started with Maven and Cucumber in Eclipse
Getting Started with Maven and Cucumber in Eclipse
Tom Arend
What's hot
(20)
Unit Testing for Great Justice
Unit Testing for Great Justice
Dependency Injection
Dependency Injection
Bowtie: Interactive Dashboards
Bowtie: Interactive Dashboards
AngularJS Unit Test
AngularJS Unit Test
Testing in AngularJS
Testing in AngularJS
Easy automation.py
Easy automation.py
It's a Kind of Magic: Under the Covers of Spring Boot
It's a Kind of Magic: Under the Covers of Spring Boot
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
Codeception presentation
Codeception presentation
Java Libraries You Can't Afford to Miss
Java Libraries You Can't Afford to Miss
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
learning react
learning react
Your code are my tests
Your code are my tests
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
The Screenplay Pattern: Better Interactions for Better Automation
The Screenplay Pattern: Better Interactions for Better Automation
Getting Started with Maven and Cucumber in Eclipse
Getting Started with Maven and Cucumber in Eclipse
Viewers also liked
World-Class Testing Development Pipeline for Android
World-Class Testing Development Pipeline for Android
Pedro Vicente Gómez Sánchez
Profile.e (yuki sato)0529
Profile.e (yuki sato)0529
Sato Yuki
Tarea 1 e busines
Tarea 1 e busines
pilarguerra08
Curso de Alta Formación en Marketing para Empresas de Servicios
Curso de Alta Formación en Marketing para Empresas de Servicios
Unibo
Brand boost by wildtangent
Brand boost by wildtangent
WildTangent
Update on the ELIXIR UK node by Chris Ponting
Update on the ELIXIR UK node by Chris Ponting
ELIXIR UK
S&B Parking Operators
S&B Parking Operators
SB Ibérica
fluke presentation voicemail on email – cisco
fluke presentation voicemail on email – cisco
Fluke Infotech
(Self) Publishing
(Self) Publishing
Vlad Micu
CompuSystems Dashboards
CompuSystems Dashboards
CompuSystems, Inc.
Examen trimestra diego reyes
Examen trimestra diego reyes
Diego Reyes
2012 Email Evolution Sneak Peak Webinar: Part 1
2012 Email Evolution Sneak Peak Webinar: Part 1
Vivastream
Servicio Eiden : Opinan nuestros clientes
Servicio Eiden : Opinan nuestros clientes
Santiago Trevisán
Status Www Undersøgelse Udenpix
Status Www Undersøgelse Udenpix
Elisabeth Tejlmand
Da schau her! Augenfreundliche Gestaltung von e-Learning Kursen
Da schau her! Augenfreundliche Gestaltung von e-Learning Kursen
Gergely Rakoczi
Parroquia de San Pedro y San Pablo (Cabanillas del Campo)
Parroquia de San Pedro y San Pablo (Cabanillas del Campo)
Javier Lozano
Estudio earcas
Estudio earcas
SociosaniTec
Dios es mi Guía
Dios es mi Guía
adeni11
Ejercicio de dinamica
Ejercicio de dinamica
Jacinto Matom Gallego
1 year with ROM on production
1 year with ROM on production
Oskar Szrajer
Viewers also liked
(20)
World-Class Testing Development Pipeline for Android
World-Class Testing Development Pipeline for Android
Profile.e (yuki sato)0529
Profile.e (yuki sato)0529
Tarea 1 e busines
Tarea 1 e busines
Curso de Alta Formación en Marketing para Empresas de Servicios
Curso de Alta Formación en Marketing para Empresas de Servicios
Brand boost by wildtangent
Brand boost by wildtangent
Update on the ELIXIR UK node by Chris Ponting
Update on the ELIXIR UK node by Chris Ponting
S&B Parking Operators
S&B Parking Operators
fluke presentation voicemail on email – cisco
fluke presentation voicemail on email – cisco
(Self) Publishing
(Self) Publishing
CompuSystems Dashboards
CompuSystems Dashboards
Examen trimestra diego reyes
Examen trimestra diego reyes
2012 Email Evolution Sneak Peak Webinar: Part 1
2012 Email Evolution Sneak Peak Webinar: Part 1
Servicio Eiden : Opinan nuestros clientes
Servicio Eiden : Opinan nuestros clientes
Status Www Undersøgelse Udenpix
Status Www Undersøgelse Udenpix
Da schau her! Augenfreundliche Gestaltung von e-Learning Kursen
Da schau her! Augenfreundliche Gestaltung von e-Learning Kursen
Parroquia de San Pedro y San Pablo (Cabanillas del Campo)
Parroquia de San Pedro y San Pablo (Cabanillas del Campo)
Estudio earcas
Estudio earcas
Dios es mi Guía
Dios es mi Guía
Ejercicio de dinamica
Ejercicio de dinamica
1 year with ROM on production
1 year with ROM on production
Similar to Droidcon ES '16 - How to fail going offline
My way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca edition
Christian Panadero
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
Darwin Biler
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
Jose Manuel Pereira Garcia
My way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca edition
Christian Panadero
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
All a flutter about Flutter.io
All a flutter about Flutter.io
Steven Cooper
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
Javascript first-class citizenery
Javascript first-class citizenery
toddbr
Net conf BG xamarin lecture
Net conf BG xamarin lecture
Tsvyatko Konov
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
Debora Gomez Bertoli
HTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
How to code to code less
How to code to code less
Anton Novikau
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Victor Rentea
Testing in android
Testing in android
jtrindade
softshake 2014 - Java EE
softshake 2014 - Java EE
Alexis Hassler
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
Konstantin Loginov
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
Daniel Fisher
Why you should be using the shiny new C# 6.0 features now!
Why you should be using the shiny new C# 6.0 features now!
Eric Phan
JS Class 2016
JS Class 2016
Yves-Emmanuel Jutard
Similar to Droidcon ES '16 - How to fail going offline
(20)
My way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca edition
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
My way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca edition
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
All a flutter about Flutter.io
All a flutter about Flutter.io
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Javascript first-class citizenery
Javascript first-class citizenery
Net conf BG xamarin lecture
Net conf BG xamarin lecture
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
HTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
How to code to code less
How to code to code less
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Testing in android
Testing in android
softshake 2014 - Java EE
softshake 2014 - Java EE
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
Why you should be using the shiny new C# 6.0 features now!
Why you should be using the shiny new C# 6.0 features now!
JS Class 2016
JS Class 2016
Recently uploaded
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
smiwainfosol
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
Diego Iván Oliveros Acosta
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
StefanoLambiase
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
confluent
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Matt Ray
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
vaddepallysandeep122
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
Lionel Briand
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
rcbcrtm
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
Tier1 app
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
Hironori Washizaki
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
FerryKemperman
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
Wave PLM
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
31events.com
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
qr0udbr0
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
OnePlan Solutions
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Drew Moseley
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
Safe Software
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Hanief Utama
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
VICTOR MAESTRE RAMIREZ
Recently uploaded
(20)
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
Droidcon ES '16 - How to fail going offline
1.
HOWTOFAIL GOING OFFLINE @droidpl javier.pedro@mobgen.com javierdepedrolopez@gmail.com
2.
JavierdePedroLópez StrengthsExperience SeniorAndroidDeveloper 3Yearsprofessionally 2Differentcompanies Freetime architecture DesignPatterns Gradle Codequality @droidpl javier.pedro@mobgen.com javierdepedrolopez@gmail.com
3.
Thistalk Try & try
& fail Architecture proposal Use case Show me the code
4.
TRY&TRY&FAIL Section 1
5.
Try&try&fail Pojos Services SyncAdapters WhyIdidinvestigate? • I work
on an SDK similar to firebase • Should work offline • Should have a simple API • Should be reliable and user friendly WhyThismatters?
6.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? • Offline improves
user experience • No loading times (most of the cases) • App always accesible • Just like magic • Makes your app less error prone • Forces the developer to think more mobile • Say no to: “you always have a good internet connection”
7.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Views/MVP/ Interactors Using POJOS Database Callback Network Callback Pojo Callback
8.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Using POJOS • Action
cancellation • Lifecycle management • Single responsibility principle broken • Messy thread management • Hard to read code • Fast to implement
9.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Views/MVP/ Interactors Using Services Service ResultReceiver/Binder Threading Database Sync Network Sync Pojo Callback
10.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Problems using Services •
Action cancellation is still a pain • Easy to leak memory • Easy to split in many services • Export to other apps • Easier to handle threading • Possibility to have many processes • Simplified callback system
11.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Views/ MVP/ Interactors Using Sync Adapters Network Sync Sync adapter Sync trigger Database (content provider) Sync Content observer
12.
Try&try&fail WhyThismatters? Pojos Services SyncAdapters WhyIdidinvestigate? Problems using Services •
Hard disconnection errors • Sync adapter documentation • Sync adapter configuration (many files) • Too linked to accounts • Uses system tools • Content change notifications • All the benefits from services
13.
ARCHITECTUREPROPOSAL Section 2
14.
ARCHITECTUREPROPOSAL ACTLOCALLY SYNCGLOBALLY
15.
LoadersArchitecture proposal Jobschedulers Alltogether Read Write Loaders Repositories Views/ MVP/ Interactors Loader inits provides data gets notified android lifecycle asks
for data Data source
16.
Loader statesArchitecture proposal Jobschedulers Alltogether Read Write Loaders Repositories Started Stopped
Reset Can load Can observe Can deliver Can load Can observe Can deliver Can load Can observe Can deliver Stop/Reset Start/Reset Start
17.
Job schedulersArchitecture proposal Jobschedulers Loaders Alltogether Read Write Repositories Pojo notifies notifies System Scheduler schedule job Preconditions check Sync Service trigger met Sync task run
task
18.
RepositoriesArchitecture proposal Jobschedulers Loaders Alltogether Read Write Repositories Data Repositorynotifies Database Repository Read Write Other sources Network repository Read Write
19.
Architecture proposal Jobschedulers Loaders Overall diagram Alltogether Read Write Repositories Data Repository Notifies Asks for data Loader Inits Provides data System Scheduler Schedule
sync Sync Service Sync task Conditions metRun task Changes data Read Write Read Write Views/ MVP/ Interactors Start App SDK write
20.
Architecture proposal Jobschedulers Loaders Alltogether Read Write Repositories SDKLoader Loader Loader Overall diagram App Layer Android SDK Entry Entry Entry Entry
21.
Architecture proposal Jobschedulers Loaders Read diagram Alltogether Read Write Repositories
22.
Architecture proposal Jobschedulers Loaders Write diagram Alltogether Read Write Repositories online
23.
USECASE Section 3
24.
Usecase Onlinesample Models offlineSample Articles and comments
25.
Usecase Onlinesample Models offlineSample
26.
Usecase Onlinesample Models offlineSample
27.
SHOWMETHECODE Section 4
28.
Classes PostActivity PostLoader PostRepository PostDAO CommentDAO PostService SyncServiceSynchronizeTask write
29.
PostActivity:init private PostRepository mRepository; private
Executor mExecutor; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRepository = DemosApplication.instance() .demoSdk() .postRepository(); mExecutor = Executors.newSingleThreadExecutor(); startLoading(); PostLoader.init(getSupportLoaderManager(), this); } Views
30.
PostActivity:loaddata @Override public Loader<List<Post>> onCreateLoader(int
id, Bundle args) { return new PostLoader(this, DemosApplication.instance().demoSdk()); } @Override public void onLoadFinished(Loader<List<Post>> loader, List<Post> data) { stopLoading(); setAdapter(data); } @Override public void onLoaderReset(@NonNull Loader<List<Post>> loader) { //Do nothing } Views
31.
PostActivity:Refresh @Override public void onRefresh()
{ startLoading(); PostLoader.getLoader(getSupportLoaderManager()).forceLoad(); } Views
32.
PostActivity:Createpost @Override public void onPostCreated(@NonNull
final Post post) { startLoading(); mExecutor.execute(() -> { try { mRepository.localCreate(post); } catch (RepositoryException e) { showError(); } }); } Views
33.
PostActivity:Deletepost @Override public void onDeleted(@NonNull
final Post post) { startLoading(); mExecutor.execute(() -> { try { mRepository.localDelete(post); } catch (RepositoryException e) { showError(); } }); } Views
34.
postloader @Override public List<Post> loadInBackground()
{ setData(mDemoSdk.postRepository().posts()); return getData(); } @Override public void registerListener() { if (mObserver == null) { mObserver = SyncService.listenForUpdates(this); } } @Override public void unregisterListener() { if (mObserver != null) { SyncService.removeUpdateListener(this, mObserver); } } loader
35.
Postrepository:allposts @WorkerThread public List<Post> posts()
{ Response<List<Post>> postsResponse = mPostService.posts().execute(); if (postsResponse.isSuccessful()) { List<Post> posts = postsResponse.body(); mPostDao.deleteAll(); mPostDao.save(posts); } return mPostDao.posts(); } datasource
36.
Postrepository:Save @WorkerThread public void localCreate(@NonNull
Post post) { mPostDao.save(post); SyncService.triggerSync(mContext); } @WorkerThread public void remoteCreate(@NonNull Post post) { Response<Post> postResponse = mPostService.create(Post.builder(post) .internalId(null) .needsSync(false) .build()).execute(); if (postResponse.isSuccessful()) { mPostDao.save(Post.builder(postResponse.body()) .internalId(post.internalId()) .build()); } } datasource
37.
Postrepository:DELETE @WorkerThread public void localDelete(@NonNull
Post post) { long now = new Date().getTime(); if (post.isNew() && post.isStoredLocally()) { mPostDao.delete(post.internalId()); SyncService.notifyChange(mContext); } else { mPostDao.save(Post.builder(post) .deletedAt(now) .updatedAt(now) .needsSync(true).build()); SyncService.triggerSync(mContext); } } @WorkerThread public void remoteDelete(@NonNull Post post) { if (mPostService.deletePost(post.id()).execute().isSuccessful() && post.isStoredLocally()) { for (Comment comment : mCommentDao.comments(post.internalId())) { remoteDelete(comment); } mPostDao.delete(post.internalId()); } } datasource
38.
Syncservice:trigger public static void
triggerSync(@NonNull Context context) { SyncService.notifyChange(context); ComponentName component = new ComponentName(context, SyncService.class); JobInfo info = new JobInfo.Builder(SYNC_SERVICE_ID, component) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .build(); getScheduler(context).schedule(info); } sync
39.
Syncservice:Listenforupdates public static BroadcastReceiver
listenForUpdates(@NonNull Loader loader) { IntentFilter filter = new IntentFilter(CHANGE_SYNC_INTENT_ACTION); SyncServiceReceiver receiver = new SyncServiceReceiver(loader); LocalBroadcastManager.getInstance(loader.getContext()) .registerReceiver(receiver, filter); return receiver; } public static void removeUpdateListener(@NonNull Loader loader, @NonNull BroadcastReceiver observer) { LocalBroadcastManager.getInstance(loader.getContext()) .unregisterReceiver(observer); } public static void notifyChange(@NonNull Context context) { LocalBroadcastManager.getInstance(context).sendBroadcast(getCompletionIntent()); } sync
40.
Syncservice:DotheJOB @Override public boolean onStartJob(JobParameters
params) { DemoSdk sdk = DemoSdk.Factory.instance(); boolean willExecute = true; if (sdk != null) { mRunningSyncTask = new SynchronizeTask(sdk, this); mRunningSyncTask.execute(params); } else { willExecute = false; } return willExecute; } sync @Override public boolean onStopJob(JobParameters params) { boolean reschedule = false; if (mRunningSyncTask != null) { mRunningSyncTask.cancel(true); reschedule = true; } return reschedule; }
41.
Synctask:Sync @Override protected JobParameters doInBackground(JobParameters...
params) { syncPosts(); syncComments(); return params[0]; } sync private void syncPosts() { List<Post> posts = mSdk.postRepository().localPendingPosts(); for (Post post : posts) { if (post.isNew()) { mSdk.postRepository().remoteCreate(post); } else if (post.isDeleted()) { mSdk.postRepository().remoteDelete(post); } } }
42.
Synctask:NOTIFY @Override protected void onPostExecute(JobParameters
jobParameters) { super.onPostExecute(jobParameters); SyncService.notifyChange(mSyncService); mSyncService.jobFinished(jobParameters, mNeedsResync); } sync
43.
Andthereyougo!yourappworksoffline
44.
SOURCECodeavailable https://github.com/droidpl/offline-architecture @droidpl
45.
Conclusions Offline matters because UX matters It
is part of the architecture Not so much effort with the right choice Unique dataflow Don’t reinvent the wheel - Android has it -
46.
…………………… Wearehiring! Ask
47.
…………………… Q&A
48.
…………………… Thankyou!
Download now