Class DatabaseHandler

java.lang.Object
com.example.skeddly.business.database.DatabaseHandler

public class DatabaseHandler extends Object
Handles edits and realtime updates to the realtime DB in Firebase
  • Constructor Details

    • DatabaseHandler

      public DatabaseHandler()
  • Method Details

    • customSerializer

      public void customSerializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object)
      Serializes a DatabaseObject into the DB
      Parameters:
      ref - The DocumentReference to serialize to
      object - The DatabaseObject to serialize
      See Also:
    • customUnserializer

      public void customUnserializer(com.google.firebase.firestore.DocumentReference ref, DatabaseObject object) throws InvocationTargetException, IllegalAccessException
      Unserializes a DatabaseObject from the DB
      Parameters:
      ref - The DocumentReference to unserialize
      object - The DatabaseObject to unserialize
      Throws:
      InvocationTargetException
      IllegalAccessException
      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 - The DocumentReference reference of the node
      internalName - The field in the document where all the IDs are stored.
      Returns:
      An asynchronous task that gets an arraylist of strings
      See Also:
      • CollectionReference
    • 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 - The CollectionReference of 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 - The DatabaseObject to serialize to (generic)
      Parameters:
      ref - The DocumentReference for the path to watch
      classType - The DatabaseObject to 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 - The DatabaseObject to serialize to (generic)
      Parameters:
      ref - The DocumentReference for the path to watch
      classType - The DatabaseObject to 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 a CollectionReference pointing to users
      Returns:
      A CollectionReference pointing to users
      See Also:
      • CollectionReference
    • getEventsPath

      public com.google.firebase.firestore.CollectionReference getEventsPath()
      Returns a CollectionReference pointing to events
      Returns:
      A CollectionReference pointing to events
      See Also:
      • CollectionReference
    • getTicketsPath

      public com.google.firebase.firestore.CollectionReference getTicketsPath()
      Returns a CollectionReference pointing to tickets
      Returns:
      A CollectionReference pointing to tickets
      See Also:
      • CollectionReference
    • getNotificationsPath

      public com.google.firebase.firestore.CollectionReference getNotificationsPath()
      Returns a CollectionReference pointing to notifications
      Returns:
      A CollectionReference pointing to notifications
      See Also:
      • CollectionReference
    • getPath

      public com.google.firebase.firestore.CollectionReference getPath(String path)
      Returns a CollectionReference pointing to the specified path
      Returns:
      A CollectionReference pointing to the specified path
      See Also:
      • CollectionReference