Class LocationPhotoStorage


  • public class LocationPhotoStorage
    extends java.lang.Object
    Singleton class to retrieve location photos stored.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deletePhoto​(QRCode qrCode, Player player, java.util.function.Consumer<java.lang.Boolean> callback)
      Deletes a player's location photo from the QRCode
      static LocationPhotoStorage getInstance()  
      void getLocationPhotos​(QRCode qrCode, java.util.function.Consumer<java.util.ArrayList<com.google.firebase.storage.StorageReference>> callback)
      Retrieves all the location photos (references) for a given QRCode
      java.lang.String getPrefix()  
      com.google.firebase.storage.StorageReference getQRCodeRef​(QRCode qrCode)
      Gets the reference for the folder containing all the location photos of the QRCode
      static void mockInstance​(LocationPhotoStorage mockInstance)
      Update the instance of the LocationPhotoStorage
      void playerHasLocationPhoto​(QRCode qrCode, Player player, java.util.function.Consumer<java.lang.Boolean> callback)
      Checks if a player has a location photo uploadedt
      void uploadPhoto​(QRCode qrCode, LocationPhoto locationPhoto, java.util.function.Consumer<java.lang.Boolean> callback)
      Uploads a location photo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocationPhotoStorage

        public LocationPhotoStorage()
    • Method Detail

      • getPrefix

        public java.lang.String getPrefix()
      • getInstance

        public static LocationPhotoStorage getInstance()
        Returns:
        Retrieves the LocationPhotoStorage
      • mockInstance

        public static void mockInstance​(LocationPhotoStorage mockInstance)
        Update the instance of the LocationPhotoStorage
        Parameters:
        mockInstance - new instance
      • getLocationPhotos

        public void getLocationPhotos​(QRCode qrCode,
                                      java.util.function.Consumer<java.util.ArrayList<com.google.firebase.storage.StorageReference>> callback)
        Retrieves all the location photos (references) for a given QRCode
        Parameters:
        qrCode - The QRCode to fetch location photos for
        callback - The callback function that handles the returned location photos
      • uploadPhoto

        public void uploadPhoto​(QRCode qrCode,
                                LocationPhoto locationPhoto,
                                java.util.function.Consumer<java.lang.Boolean> callback)
        Uploads a location photo

        The format of the photo's URL is `[QRCodeHash]/[PlayerDocId]`

        Adapted from https://firebase.google.com/docs/storage/android/upload-files

        License: Apache 2.0

        Parameters:
        qrCode - The QRCode associated with the location photo
        locationPhoto - The location photo to upload
        callback - The callback function that handles result of upload
      • deletePhoto

        public void deletePhoto​(QRCode qrCode,
                                Player player,
                                java.util.function.Consumer<java.lang.Boolean> callback)
        Deletes a player's location photo from the QRCode
        Parameters:
        qrCode - The QRCode to delete location photo from
        player - The Player who'd like to delete their location photo
        callback - The callback function that handles result of deletion
      • playerHasLocationPhoto

        public void playerHasLocationPhoto​(QRCode qrCode,
                                           Player player,
                                           java.util.function.Consumer<java.lang.Boolean> callback)
        Checks if a player has a location photo uploadedt
        Parameters:
        qrCode - The QRCode we check if player has a location photo of
        player - The player of interest
        callback - The callback function to handle the result of the query
      • getQRCodeRef

        public com.google.firebase.storage.StorageReference getQRCodeRef​(QRCode qrCode)
        Gets the reference for the folder containing all the location photos of the QRCode
        Parameters:
        qrCode - The QRCode to fetch location photos of
        Returns:
        A StorageReference pointing to the folder of the QRCode's location photos