dynamite8 / resources-android-dev

Collection of resources for becoming an Android developer
7 stars 7 forks source link

Link Firebase Data into Room DB Repository #77

Closed dynamite8 closed 6 years ago

JaeW commented 6 years ago

@dynamite8 your PR re Firebase integration has been approved.

Here is a repo using MVVM architecture which pulls Firebase data into a ViewModel as it does not have a repository, but the concept is the same.

https://github.com/saksham24/Android-Firebase-Mvp-Mvc-Mvvm-chat/blob/master/Chatmvvm%20-%20Java/app/src/main/java/nosql/anew/chatmvvm/viewModels/ChatViewModel.java#L34

Also note that additions to the db should be made on a non-UI thread. Example here: https://android.jlelse.eu/pre-populate-room-database-6920f9acc870