This document includes layout and data model in this spike exercise as well as Google Firebase authentication, Firestore and Storage example.
UW students want to find roomates by posting houseing resource such as housename, address, descriptions and price. All users can view the housing resources while only registered users can post housing resource and leave comments.
The layout is build on Google Login Activity and Navigation Drawer Activity which servers as the main activity. Each fragment in Navigation Drawer Activity uses Recycler View and Card View for listing all data.
The Login Activity and Sign up activity handles firebase authentication and writes all data to the user class.
Firebase firestore is a NoSQL database. Collections and Documents are used to organized the data. In this project, Firestore has two collections: Housemarket and User.
Housemarket contains current housing resource in the market in which each house has its own document. Each house is given a unique id represented by document ID. Each house document contains the housename, price and descriptions. Recycler adapter later fetch all docuemnts to the memory and read in the information within each docuemnts.
- Collection("Housemarket")
- Document()
- String description
- String housename
- String ownerID
- number price
- Document()
User collection contains all information of users. Once a new user is created through signup actiivty, a new document is created. The document ID is generated by the Firebase Authentication when a new user is registered and its own unique user id is generated.
User collection also contains the houselist which the user current owns and other profile information such as phone except for the password.
- Collection("User")
- Document()
- String Email
- Array Myhouses
- String houseid
- String Phone
- String Username
- Document()
In this example, Firebase storage contains all images. The image of each house is stored in /houseimg
folder, and the name of the file is the house ID generated which is also the document ID.
House class stores information of each house.
- Class House
- String housename
- String description
- Double price
- String ownerID
User class is a static class. Since only one user is allowed to logged in, all fields and methods are static. In the future, the Login Activity and Signup Activity will only handle the GUI and pass all pass all parameters to User class for firebase authentication.
- Class User
- String Username
- String Email
- String ArrayList Myhouses
- String Phone
- Boolean LoginStatus
- String UID
- Boolean signout()
- Boolean getUser()
Market class stores profile of all houses currently in the market. The market stores the arraylist of houses and also handle firestore process.
- Class Market
- ArrayList market
- FirebaseFirestore db
- CollectionReference MarketDB // Firebase firestore database collection reference
- void marketinitialize()
- void updatemarket() // Call Firestore method and update the local data
- void updatehouse(QueryDocumentSnapshot) // Add each house to market List during updating local data.
Myhouses class stores profile of all houses owned by the current user. This class stores arraylist of houses and also handle firestore process. When update even is triggered, the class first fetch all houseID under collection("User").docuemnt(<User ID>).Array("Myhouses")
. Next, method will fetch the document from collection("Market").docuemnt(<House ID>)
and fill all information to this class.
- Class Myhouses
- List myhouses
- FirebaseFirestore db
- CollectionReference UserDB
- CollectionReference MarketDB
- void myhouseinitialize()
- void update()
- void updatehousebyid(String)
- User Login and Register
- Get data from firestore
- User Profile
- Market/Housing Resource overview
- Get data from Firestore
- Recycler and Card View
- 9.18 Start learning Android Studio
- 9.21 Start learning Firebase
- 9.25 Start buidling login and register GUI
- 9.27 Complete login and register GUI design, start connect to Firebase Authentication.
- 9.28 Sucessfully implement firebase authentication, start connecting to Firestore
- 9.30 Complete Firestore connection, start designing main activity
- 10.2 Complte Main activity - Home Fragment Recycler and Card View design as well as fetch house market data from firestore, start implementing Firebase storage.
- 10.4 Still working on Firebase storage, giveing up...
- 10.11 Prepare for demo, still can't connect to Cloud Storage.
- Move User authentication from Login and Signup Acitivty to User class.
- Create a new datalayer that handle all cloud traffic.
- All classes or activities that need to cloud IO will call method in this class which will perform the task with its cloud instance in this class.
- Migrate to any newer framework if needed to reduce workload.
- Write a Kotlin version.
- Design the architect, data model and draw out the class diagram ahead before starting.
- Write wiki page for framwork and any external API.