Class LocationPhotoStorage
- java.lang.Object
-
- com.cmput301w23t09.qrhunter.locationphoto.LocationPhotoStorage
-
public class LocationPhotoStorage extends java.lang.ObjectSingleton class to retrieve location photos stored.
-
-
Constructor Summary
Constructors Constructor Description LocationPhotoStorage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeletePhoto(QRCode qrCode, Player player, java.util.function.Consumer<java.lang.Boolean> callback)Deletes a player's location photo from the QRCodestatic LocationPhotoStoragegetInstance()voidgetLocationPhotos(QRCode qrCode, java.util.function.Consumer<java.util.ArrayList<com.google.firebase.storage.StorageReference>> callback)Retrieves all the location photos (references) for a given QRCodejava.lang.StringgetPrefix()com.google.firebase.storage.StorageReferencegetQRCodeRef(QRCode qrCode)Gets the reference for the folder containing all the location photos of the QRCodestatic voidmockInstance(LocationPhotoStorage mockInstance)Update the instance of the LocationPhotoStoragevoidplayerHasLocationPhoto(QRCode qrCode, Player player, java.util.function.Consumer<java.lang.Boolean> callback)Checks if a player has a location photo uploadedtvoiduploadPhoto(QRCode qrCode, LocationPhoto locationPhoto, java.util.function.Consumer<java.lang.Boolean> callback)Uploads a location photo
-
-
-
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 forcallback- 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 photoThe 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 photolocationPhoto- The location photo to uploadcallback- 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 fromplayer- The Player who'd like to delete their location photocallback- 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 ofplayer- The player of interestcallback- 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
-
-