Class DatabaseHandler
java.lang.Object
com.example.skeddly.business.database.DatabaseHandler
Handles edits and realtime updates to the realtime DB in Firebase
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcustomSerializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object) Serializes aDatabaseObjectinto the DBvoidcustomUnserializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object) Unserializes aDatabaseObjectfrom the DBcom.google.firebase.firestore.CollectionReferenceReturns aCollectionReferencepointing to events<T extends DatabaseObject>
com.google.android.gms.tasks.Task<DatabaseObjects<T>> getNodeChildren(com.google.firebase.firestore.CollectionReference ref, Class<T> classType) Gets the children of a node in the database.getNodeChildren(com.google.firebase.firestore.DocumentReference ref, String internalName) Gets the children of a node in the database.com.google.firebase.firestore.CollectionReferenceReturns aCollectionReferencepointing to notificationscom.google.firebase.firestore.CollectionReferenceReturns aCollectionReferencepointing to the specified pathcom.google.firebase.firestore.CollectionReferenceReturns aCollectionReferencepointing to ticketscom.google.firebase.firestore.CollectionReferenceReturns aCollectionReferencepointing to users<T extends DatabaseObject>
com.google.firebase.firestore.ListenerRegistrationiterableListen(com.google.firebase.firestore.CollectionReference ref, Class<T> classType, IterableListenUpdate callback) Listens to if a group of values are updated in a specific part of the DB<T extends DatabaseObject>
com.google.firebase.firestore.ListenerRegistrationsingleListen(com.google.firebase.firestore.DocumentReference ref, Class<T> classType, SingleListenUpdate<T> callback) Listens to if a single value is updated in a specific part of the DB
-
Constructor Details
-
DatabaseHandler
public DatabaseHandler()
-
-
Method Details
-
customSerializer
public void customSerializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object) Serializes aDatabaseObjectinto the DB- Parameters:
ref- TheDocumentReferenceto serialize toobject- TheDatabaseObjectto serialize- See Also:
-
customUnserializer
public void customUnserializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object) throws InvocationTargetException, IllegalAccessException Unserializes aDatabaseObjectfrom the DB- Parameters:
ref- TheDocumentReferenceto unserializeobject- TheDatabaseObjectto unserialize- Throws:
InvocationTargetExceptionIllegalAccessException- See Also:
-
getNodeChildren
public com.google.android.gms.tasks.Task<ArrayList<String>> getNodeChildren(com.google.firebase.firestore.DocumentReference ref, String internalName) Gets the children of a node in the database.- Parameters:
ref- TheDocumentReferencereference of the nodeinternalName- The field in the document where all the IDs are stored.- Returns:
- An asynchronous task that gets an arraylist of strings
- See Also:
-
getNodeChildren
public <T extends DatabaseObject> com.google.android.gms.tasks.Task<DatabaseObjects<T>> getNodeChildren(com.google.firebase.firestore.CollectionReference ref, Class<T> classType) Gets the children of a node in the database.- Parameters:
ref- TheCollectionReferenceof the node that contains the children.- Returns:
- An asynchronous task that gets an arraylist of database objects
-
singleListen
public <T extends DatabaseObject> com.google.firebase.firestore.ListenerRegistration singleListen(com.google.firebase.firestore.DocumentReference ref, Class<T> classType, SingleListenUpdate<T> callback) Listens to if a single value is updated in a specific part of the DB- Type Parameters:
T- TheDatabaseObjectto serialize to (generic)- Parameters:
ref- TheDocumentReferencefor the path to watchclassType- TheDatabaseObjectto serialize to (generic)callback- The SingleListenUpdate to use as a callback for when data is changed- See Also:
-
iterableListen
public <T extends DatabaseObject> com.google.firebase.firestore.ListenerRegistration iterableListen(com.google.firebase.firestore.CollectionReference ref, Class<T> classType, IterableListenUpdate callback) Listens to if a group of values are updated in a specific part of the DB- Type Parameters:
T- TheDatabaseObjectto serialize to (generic)- Parameters:
ref- TheDocumentReferencefor the path to watchclassType- TheDatabaseObjectto serialize to (generic)callback- The SingleListenUpdate to use as a callback for when data is changed- See Also:
-
getUsersPath
public com.google.firebase.firestore.CollectionReference getUsersPath()Returns aCollectionReferencepointing to users- Returns:
- A
CollectionReferencepointing to users - See Also:
-
getEventsPath
public com.google.firebase.firestore.CollectionReference getEventsPath()Returns aCollectionReferencepointing to events- Returns:
- A
CollectionReferencepointing to events - See Also:
-
getTicketsPath
public com.google.firebase.firestore.CollectionReference getTicketsPath()Returns aCollectionReferencepointing to tickets- Returns:
- A
CollectionReferencepointing to tickets - See Also:
-
getNotificationsPath
public com.google.firebase.firestore.CollectionReference getNotificationsPath()Returns aCollectionReferencepointing to notifications- Returns:
- A
CollectionReferencepointing to notifications - See Also:
-
getPath
Returns aCollectionReferencepointing to the specified path- Returns:
- A
CollectionReferencepointing to the specified path - See Also:
-