SlideShare a Scribd company logo
Android architecture
components with cloud firestore
Pankaj Rai
@raipankaj7
Agenda ● Android architecture components
● Firebase services
● Cloud firestore
● What’s new in firebase
What is AAC?
Android Jetpack
Accelerate app development
Eliminate boilerplate code
Build high quality apps
Android
Architecture
Component
● Design robust, testable and
maintainable apps
● Handle data persistence
● Reduce app development time
● Improve app quality
ViewModel ● Designed to store and manage UI-related
data with lifecycle awareness
● Live through the configuration changes
● Caution: ViewModel does not replace
onSaveInstanceState()
ViewModel
(cont)
LiveData ● Observable data holder class
● Respect lifecycle of app components, such
as activities, fragments or services
● Only notifies active observers about updates
● Inactive observers registered to watch
LiveData objects aren't notified about
changes
Crash due to stopped activity
Why
LiveData?
● No memory leaks
● No crashes due to stopped activities
● No more manual lifecycle handling
● Always up to date data
LiveData which publicly exposes setValue(T) and postValue(T) method
MutableLiveData<Boolean> userIdLiveData = new MutableLiveData()
userIdLiveData.setValue(true)
MutableLiveData
LiveData subclass which may observe other LiveData objects and react on
OnChanged events from them
LiveData liveData1 = ...;
LiveData liveData2 = ...;
MediatorLiveData liveDataMerger = new MediatorLiveData<>();
liveDataMerger.addSource(liveData1,value ->liveDataMerger.setValue(value));
liveDataMerger.addSource(liveData2,value ->liveDataMerger.setValue(value));
MediatorLiveData
Applies the given function on the main thread to each value emitted by
source LiveData and returns LiveData, which emits resulting values
LiveData userLiveData = ...
LiveData userName = Transformations.map(userLiveData, user -> {
return user.firstName + " " + user.lastName; // Returns String
}
)
Transformations.map
Reacts on changes of trigger LiveData, applies the given function to new
value of trigger LiveData and sets resulting LiveData as a "backing"
LiveData
MutableLiveData userIdLiveData = ...
LiveData userLiveData = Transformations.switchMap(userIdLiveData, id ->
repository.getUserById(id) // Returns LiveData
)
void setUserId(String userId) { this.userIdLiveData.setValue(userId) }
Transformations.switchMap
Firebase
A comprehensive app development platform
Why
Firebase?
● Available for Android, iOS and Web
● Reduce time for app development
● All in one platform to build app or website
● Helps to grow your business
● Auto scale your app to support billions of users
2M28 days active apps
Cloud Firestore
● It’s NoSQL document database for mobile and web
app development
● Cloud Firestore also offers seamless integration
with other Firebase and Google Cloud Platform
products, including Cloud Functions
● It keeps your data in sync across client apps
through real-time listeners and offers offline support
for mobile and web
Why cloud
firestore?
● Documents and collections structure with powerful
querying capability
● Automatic multi-region data replication with strong
consistency
● Real-time data synchronization
● Android, iOS and Web SDKs with offline data
access
Key
capabilities
Collections are like a container which itself do not
store any data but contains document which in
turn stores data
Collection
It’s the smallest unit to store data in the database
more set of data type are now supported with
document
Document
Write to database
// Create a new user with a first and last name
val user = HashMap<String, Any>()
user["first"] = "Ada"
user["last"] = "Lovelace"
user["born"] = 1815
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener { documentReference ->
Log.d(TAG, "DocumentSnapshot added with ID: ${documentReference.id}")
}
.addOnFailureListener { e ->
Log.w(TAG, "Error adding document", e)
}
val city = HashMap<String, Any>()
city["name"] = "Los Angeles"
city["state"] = "CA"
city["country"] = "USA"
db.collection("cities").document("LA")
.set(city) or set(data, SetOptions.merge())
.addOnSuccessListener { Log.d(TAG, "DocumentSnapshot
successfully written!") }
.addOnFailureListener { e -> Log.w(TAG, "Error writing document", e) }
Read from database
db.collection("users")
.get()
.addOnSuccessListener { result ->
for (document in result) {
Log.d(TAG, "${document.id} => ${document.data}")
}
}
.addOnFailureListener { exception ->
Log.w(TAG, "Error getting documents.", exception)
}
db.collection("cities")
.whereEqualTo("capital", true)
.get()
.addOnSuccessListener { documents ->
for (document in documents) {
Log.d(TAG, "${document.id} => ${document.data}")
}
}
.addOnFailureListener { exception ->
Log.w(TAG, "Error getting documents: ", exception)
}
FirebaseFirestore.getInstance().collection("sd").whereEqualTo("state","ca").addSnapshotListener(this) { snapshot,
e ->
if (e != null) {
Log.w(TAG, "listen:error", e)
return@EventListener
}
for (dc in snapshots.documentChanges) {
when (dc.type) {
DocumentChange.Type.ADDED -> Log.d(TAG, "New city: ${dc.document.data}")
DocumentChange.Type.MODIFIED -> Log.d(TAG, "Modified city: ${dc.document.data}")
DocumentChange.Type.REMOVED -> Log.d(TAG, "Removed city: ${dc.document.data}")
}
}
}
Combined with AAC
object NetworkRepository {
fun registerAttendee(map: Map<String, Any?>): LiveData<Boolean> {
val mutableLiveData = MutableLiveData<Boolean>()
FirebaseFirestore.getInstance().collection(AppConstant.ATTENDEES)
.document(map.getValue(AppConstant.ATTENDEE_EMAIL).toString())
.set(map)
.addOnCompleteListener{
mutableLiveData.value = it.isSuccessful
}
return mutableLiveData
}
}
class AttendeesViewModel: ViewModel() {
private val _registerAttendee = MutableLiveData<Map<String, Any?>>()
val registerAttendee = _registerAttendee.switchMap {
NetworkRepository.registerAttendee(it)
}
fun setRegAttendeeInfo(map: Map<String, Any?>) {
_registerAttendee.value = map
}
}
val attendeesDetails = mapOf(
AppConstant.ATTENDEE_EMAIL to mAttendeeEmail,
AppConstant.TIMESTAMP to FieldValue.serverTimestamp()
)
//Send the attendees details to firestore
mAttendeesViewModel.setRegAttendeeInfo(attendeesDetails)
//Observe the result from firestore
mAttendeesViewModel.registerAttendee.observe(this, Observer {
...
...
})
What’s new in Firebase?
● Analytics for web
● FCM for web
● Remote config for web
● Firebase Extensions
● Firebase App Distributions
Firebase
Extensions
Firebase
App
Distribution
● It makes distributing your apps to trusted testers
easy
● Get stability metrics for all your builds
● Distribute builds using the Firebase console, the
Firebase Command Line Interface (CLI) tool or
Gradle (Android)
How to
distribute
app?
● Upload the APK or IPA to App Distribution using the
Firebase console, Gradle, or the CLI tools
● Add the testers you want to try your app. Testers will
receive an email that walks them through the
onboarding process
● When new build is ready for testing, just upload it to
App Distribution. Your testers will be notified that a
new build is available to try out
Thank You
Pankaj Rai
https://twitter.com/raipankaj7

More Related Content

What's hot

A practical approach for naming elements in Adobe Launch
A practical approach for naming elements in Adobe LaunchA practical approach for naming elements in Adobe Launch
A practical approach for naming elements in Adobe Launch
Kevin Haag
 
CData Power BI Connectors
CData Power BI ConnectorsCData Power BI Connectors
CData Power BI Connectors
Jerod Johnson
 
Azure Data Factory Data Flow
Azure Data Factory Data FlowAzure Data Factory Data Flow
Azure Data Factory Data Flow
Mark Kromer
 
Data Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQLData Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQL
DATAVERSITY
 
Feature store Overview St. Louis Big Data IDEA Meetup aug 2020
Feature store Overview   St. Louis Big Data IDEA Meetup aug 2020Feature store Overview   St. Louis Big Data IDEA Meetup aug 2020
Feature store Overview St. Louis Big Data IDEA Meetup aug 2020
Adam Doyle
 
AIC x PyLadies TW Python Data Vis - 3: Dashboard
AIC x PyLadies TW Python Data Vis - 3: DashboardAIC x PyLadies TW Python Data Vis - 3: Dashboard
AIC x PyLadies TW Python Data Vis - 3: Dashboard
Yi-Chih Tsai
 
ASP.Net 3.5 SP1 Dynamic Data
ASP.Net 3.5 SP1 Dynamic DataASP.Net 3.5 SP1 Dynamic Data
ASP.Net 3.5 SP1 Dynamic Data
micham
 
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Andrew Rota
 
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
Chester Chen
 
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy NguyenGrokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Huy Nguyen
 
CCT Check and Calculate Transfer
CCT Check and Calculate TransferCCT Check and Calculate Transfer
CCT Check and Calculate Transfer
Francesca Pappalardo
 
Kliq planflyer
Kliq planflyerKliq planflyer
Kliq planflyerCL0905
 
Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019
Andrew Rota
 
How to write your database: the story about Event Store
How to write your database: the story about Event StoreHow to write your database: the story about Event Store
How to write your database: the story about Event Store
Victor Haydin
 
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
Sriskandarajah Suhothayan
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
Erik-Berndt Scheper
 
BigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQLBigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQL
Márton Kodok
 
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
DataStax Academy
 
Jean-René Roy : The Modern DBA
Jean-René Roy : The Modern DBAJean-René Roy : The Modern DBA
Jean-René Roy : The Modern DBA
MSDEVMTL
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage Data
Tariq Iqbal
 

What's hot (20)

A practical approach for naming elements in Adobe Launch
A practical approach for naming elements in Adobe LaunchA practical approach for naming elements in Adobe Launch
A practical approach for naming elements in Adobe Launch
 
CData Power BI Connectors
CData Power BI ConnectorsCData Power BI Connectors
CData Power BI Connectors
 
Azure Data Factory Data Flow
Azure Data Factory Data FlowAzure Data Factory Data Flow
Azure Data Factory Data Flow
 
Data Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQLData Modeling and Relational to NoSQL
Data Modeling and Relational to NoSQL
 
Feature store Overview St. Louis Big Data IDEA Meetup aug 2020
Feature store Overview   St. Louis Big Data IDEA Meetup aug 2020Feature store Overview   St. Louis Big Data IDEA Meetup aug 2020
Feature store Overview St. Louis Big Data IDEA Meetup aug 2020
 
AIC x PyLadies TW Python Data Vis - 3: Dashboard
AIC x PyLadies TW Python Data Vis - 3: DashboardAIC x PyLadies TW Python Data Vis - 3: Dashboard
AIC x PyLadies TW Python Data Vis - 3: Dashboard
 
ASP.Net 3.5 SP1 Dynamic Data
ASP.Net 3.5 SP1 Dynamic DataASP.Net 3.5 SP1 Dynamic Data
ASP.Net 3.5 SP1 Dynamic Data
 
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
 
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
SF big Analytics : Stream all things by Gwen Shapira @ Lyft 2018
 
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy NguyenGrokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
Grokking Engineering - Data Analytics Infrastructure at Viki - Huy Nguyen
 
CCT Check and Calculate Transfer
CCT Check and Calculate TransferCCT Check and Calculate Transfer
CCT Check and Calculate Transfer
 
Kliq planflyer
Kliq planflyerKliq planflyer
Kliq planflyer
 
Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019
 
How to write your database: the story about Event Store
How to write your database: the story about Event StoreHow to write your database: the story about Event Store
How to write your database: the story about Event Store
 
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
WSO2 Stream Processor: Graphical Editor, HTTP & Message Trace Analytics and m...
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
 
BigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQLBigQuery ML - Machine learning at scale using SQL
BigQuery ML - Machine learning at scale using SQL
 
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
C* Summit 2013: Optimizing the Public Cloud for Cost and Scalability with Cas...
 
Jean-René Roy : The Modern DBA
Jean-René Roy : The Modern DBAJean-René Roy : The Modern DBA
Jean-René Roy : The Modern DBA
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage Data
 

Similar to Android architecture components with cloud firestore

Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018
Hassan Abid
 
Firestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabiFirestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabi
Shashank Kakroo
 
Firebase
Firebase Firebase
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
Ahmad Arif Faizin
 
Giga Spaces Data Grid / Data Caching Overview
Giga Spaces Data Grid / Data Caching OverviewGiga Spaces Data Grid / Data Caching Overview
Giga Spaces Data Grid / Data Caching Overview
jimliddle
 
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DBBuilding event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
Microsoft Tech Community
 
Why and How SmartNews uses SaaS?
Why and How SmartNews uses SaaS?Why and How SmartNews uses SaaS?
Why and How SmartNews uses SaaS?
Takumi Sakamoto
 
Google Firebase presentation - English
Google Firebase presentation - EnglishGoogle Firebase presentation - English
Google Firebase presentation - English
Alexandros Tsichouridis
 
Firebase overview
Firebase overviewFirebase overview
Firebase overview
Maksym Davydov
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservicesDecomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservices
Dennis Doomen
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
Vlad Filippov
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
ukdpe
 
Azure data analytics platform - A reference architecture
Azure data analytics platform - A reference architecture Azure data analytics platform - A reference architecture
Azure data analytics platform - A reference architecture
Rajesh Kumar
 
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Codemotion
 
About The Event-Driven Data Layer & Adobe Analytics
About The Event-Driven Data Layer & Adobe AnalyticsAbout The Event-Driven Data Layer & Adobe Analytics
About The Event-Driven Data Layer & Adobe Analytics
Kevin Haag
 
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQueryCodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
Márton Kodok
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
Software Park Thailand
 
Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure
Chris Pietschmann (Microsoft MVP)
 
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration MondayBuilding workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
BizTalk360
 

Similar to Android architecture components with cloud firestore (20)

Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018
 
Firestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabiFirestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabi
 
Firebase
Firebase Firebase
Firebase
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Giga Spaces Data Grid / Data Caching Overview
Giga Spaces Data Grid / Data Caching OverviewGiga Spaces Data Grid / Data Caching Overview
Giga Spaces Data Grid / Data Caching Overview
 
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DBBuilding event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
Building event-driven Serverless Apps with Azure Functions and Azure Cosmos DB
 
Why and How SmartNews uses SaaS?
Why and How SmartNews uses SaaS?Why and How SmartNews uses SaaS?
Why and How SmartNews uses SaaS?
 
Google Firebase presentation - English
Google Firebase presentation - EnglishGoogle Firebase presentation - English
Google Firebase presentation - English
 
Firebase overview
Firebase overviewFirebase overview
Firebase overview
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservicesDecomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservices
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
Azure data analytics platform - A reference architecture
Azure data analytics platform - A reference architecture Azure data analytics platform - A reference architecture
Azure data analytics platform - A reference architecture
 
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
Sebastian Schmidt, Rachel Myers - How To Go Serverless And Not Violate The GD...
 
About The Event-Driven Data Layer & Adobe Analytics
About The Event-Driven Data Layer & Adobe AnalyticsAbout The Event-Driven Data Layer & Adobe Analytics
About The Event-Driven Data Layer & Adobe Analytics
 
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQueryCodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
 
Stmik bandung
Stmik bandungStmik bandung
Stmik bandung
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure
 
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration MondayBuilding workflow solution with Microsoft Azure and Cloud | Integration Monday
Building workflow solution with Microsoft Azure and Cloud | Integration Monday
 

Recently uploaded

Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Dutch Power
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
Frederic Leger
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
amekonnen
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AwangAniqkmals
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Rosie Wells
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
gharris9
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
kkirkland2
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Dutch Power
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 

Recently uploaded (19)

Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 

Android architecture components with cloud firestore

  • 1. Android architecture components with cloud firestore Pankaj Rai @raipankaj7
  • 2. Agenda ● Android architecture components ● Firebase services ● Cloud firestore ● What’s new in firebase
  • 4. Android Jetpack Accelerate app development Eliminate boilerplate code Build high quality apps
  • 5. Android Architecture Component ● Design robust, testable and maintainable apps ● Handle data persistence ● Reduce app development time ● Improve app quality
  • 6. ViewModel ● Designed to store and manage UI-related data with lifecycle awareness ● Live through the configuration changes ● Caution: ViewModel does not replace onSaveInstanceState()
  • 8. LiveData ● Observable data holder class ● Respect lifecycle of app components, such as activities, fragments or services ● Only notifies active observers about updates ● Inactive observers registered to watch LiveData objects aren't notified about changes
  • 9. Crash due to stopped activity
  • 10. Why LiveData? ● No memory leaks ● No crashes due to stopped activities ● No more manual lifecycle handling ● Always up to date data
  • 11. LiveData which publicly exposes setValue(T) and postValue(T) method MutableLiveData<Boolean> userIdLiveData = new MutableLiveData() userIdLiveData.setValue(true) MutableLiveData
  • 12. LiveData subclass which may observe other LiveData objects and react on OnChanged events from them LiveData liveData1 = ...; LiveData liveData2 = ...; MediatorLiveData liveDataMerger = new MediatorLiveData<>(); liveDataMerger.addSource(liveData1,value ->liveDataMerger.setValue(value)); liveDataMerger.addSource(liveData2,value ->liveDataMerger.setValue(value)); MediatorLiveData
  • 13. Applies the given function on the main thread to each value emitted by source LiveData and returns LiveData, which emits resulting values LiveData userLiveData = ... LiveData userName = Transformations.map(userLiveData, user -> { return user.firstName + " " + user.lastName; // Returns String } ) Transformations.map
  • 14. Reacts on changes of trigger LiveData, applies the given function to new value of trigger LiveData and sets resulting LiveData as a "backing" LiveData MutableLiveData userIdLiveData = ... LiveData userLiveData = Transformations.switchMap(userIdLiveData, id -> repository.getUserById(id) // Returns LiveData ) void setUserId(String userId) { this.userIdLiveData.setValue(userId) } Transformations.switchMap
  • 15. Firebase A comprehensive app development platform
  • 16. Why Firebase? ● Available for Android, iOS and Web ● Reduce time for app development ● All in one platform to build app or website ● Helps to grow your business ● Auto scale your app to support billions of users
  • 17.
  • 20. ● It’s NoSQL document database for mobile and web app development ● Cloud Firestore also offers seamless integration with other Firebase and Google Cloud Platform products, including Cloud Functions ● It keeps your data in sync across client apps through real-time listeners and offers offline support for mobile and web Why cloud firestore?
  • 21. ● Documents and collections structure with powerful querying capability ● Automatic multi-region data replication with strong consistency ● Real-time data synchronization ● Android, iOS and Web SDKs with offline data access Key capabilities
  • 22.
  • 23. Collections are like a container which itself do not store any data but contains document which in turn stores data Collection
  • 24. It’s the smallest unit to store data in the database more set of data type are now supported with document Document
  • 26. // Create a new user with a first and last name val user = HashMap<String, Any>() user["first"] = "Ada" user["last"] = "Lovelace" user["born"] = 1815 // Add a new document with a generated ID db.collection("users") .add(user) .addOnSuccessListener { documentReference -> Log.d(TAG, "DocumentSnapshot added with ID: ${documentReference.id}") } .addOnFailureListener { e -> Log.w(TAG, "Error adding document", e) }
  • 27. val city = HashMap<String, Any>() city["name"] = "Los Angeles" city["state"] = "CA" city["country"] = "USA" db.collection("cities").document("LA") .set(city) or set(data, SetOptions.merge()) .addOnSuccessListener { Log.d(TAG, "DocumentSnapshot successfully written!") } .addOnFailureListener { e -> Log.w(TAG, "Error writing document", e) }
  • 29. db.collection("users") .get() .addOnSuccessListener { result -> for (document in result) { Log.d(TAG, "${document.id} => ${document.data}") } } .addOnFailureListener { exception -> Log.w(TAG, "Error getting documents.", exception) }
  • 30. db.collection("cities") .whereEqualTo("capital", true) .get() .addOnSuccessListener { documents -> for (document in documents) { Log.d(TAG, "${document.id} => ${document.data}") } } .addOnFailureListener { exception -> Log.w(TAG, "Error getting documents: ", exception) }
  • 31. FirebaseFirestore.getInstance().collection("sd").whereEqualTo("state","ca").addSnapshotListener(this) { snapshot, e -> if (e != null) { Log.w(TAG, "listen:error", e) return@EventListener } for (dc in snapshots.documentChanges) { when (dc.type) { DocumentChange.Type.ADDED -> Log.d(TAG, "New city: ${dc.document.data}") DocumentChange.Type.MODIFIED -> Log.d(TAG, "Modified city: ${dc.document.data}") DocumentChange.Type.REMOVED -> Log.d(TAG, "Removed city: ${dc.document.data}") } } }
  • 33. object NetworkRepository { fun registerAttendee(map: Map<String, Any?>): LiveData<Boolean> { val mutableLiveData = MutableLiveData<Boolean>() FirebaseFirestore.getInstance().collection(AppConstant.ATTENDEES) .document(map.getValue(AppConstant.ATTENDEE_EMAIL).toString()) .set(map) .addOnCompleteListener{ mutableLiveData.value = it.isSuccessful } return mutableLiveData } }
  • 34. class AttendeesViewModel: ViewModel() { private val _registerAttendee = MutableLiveData<Map<String, Any?>>() val registerAttendee = _registerAttendee.switchMap { NetworkRepository.registerAttendee(it) } fun setRegAttendeeInfo(map: Map<String, Any?>) { _registerAttendee.value = map } }
  • 35. val attendeesDetails = mapOf( AppConstant.ATTENDEE_EMAIL to mAttendeeEmail, AppConstant.TIMESTAMP to FieldValue.serverTimestamp() ) //Send the attendees details to firestore mAttendeesViewModel.setRegAttendeeInfo(attendeesDetails) //Observe the result from firestore mAttendeesViewModel.registerAttendee.observe(this, Observer { ... ... })
  • 36. What’s new in Firebase?
  • 37. ● Analytics for web ● FCM for web ● Remote config for web ● Firebase Extensions ● Firebase App Distributions
  • 39. Firebase App Distribution ● It makes distributing your apps to trusted testers easy ● Get stability metrics for all your builds ● Distribute builds using the Firebase console, the Firebase Command Line Interface (CLI) tool or Gradle (Android)
  • 40. How to distribute app? ● Upload the APK or IPA to App Distribution using the Firebase console, Gradle, or the CLI tools ● Add the testers you want to try your app. Testers will receive an email that walks them through the onboarding process ● When new build is ready for testing, just upload it to App Distribution. Your testers will be notified that a new build is available to try out
  • 41.
  • 42.