Package com.example.qrgo.firebase
Class QRCodeFirebaseManager
- java.lang.Object
-
- com.example.qrgo.firebase.BaseFirebaseConnectManager
-
- com.example.qrgo.firebase.QRCodeFirebaseManager
-
public class QRCodeFirebaseManager extends BaseFirebaseConnectManager
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.firebase.storage.FirebaseStorage
st
-
Fields inherited from class com.example.qrgo.firebase.BaseFirebaseConnectManager
db
-
-
Constructor Summary
Constructors Constructor Description QRCodeFirebaseManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteUserFromQRCode(java.lang.String qrString, java.lang.String username, OnUserDeleteFromQRCodeListener listener)
Deletes a user's username from a QR code's scannedUsers array in the database.void
getAllQrCoordinates(OnCoordinatesListLoadedListener listener)
A function that retrieves a list of all qr coordinates.void
getComments(com.google.firebase.firestore.DocumentSnapshot documentSnapshot, OnCommentsLoadedListener listener)
void
getQRCode(java.lang.String qrString, QRCodeListener listener)
Retrieves a QRCode from the Firestore database given a QR string.void
getQrCodesSortedByPoints(OnQrListLoadedListener listener)
A function that retrieves a list of qr codes sorted by its points.void
getScannedUsers(com.google.firebase.firestore.DocumentSnapshot documentSnapshot, OnScannedUsersLoadedListener listener)
void
scanQRCode(java.lang.String qrString, java.lang.String username, java.lang.String humanReadableQR, double latitude, double longitude, java.lang.String photoUrl, int points, java.util.ArrayList<java.lang.Integer> featureList, OnQRCodeScannedListener listener)
Scans a QR code and updates the user's profile and the QR code document in the database accordingly.void
uploadAndRetrieveDownloadUrl(android.net.Uri file, java.lang.String qrString, OnQRCodeUploadListener listener)
Uploads a file to Firebase Storage and retrieves the download URL.
-
-
-
Method Detail
-
scanQRCode
public void scanQRCode(java.lang.String qrString, java.lang.String username, java.lang.String humanReadableQR, double latitude, double longitude, java.lang.String photoUrl, int points, java.util.ArrayList<java.lang.Integer> featureList, OnQRCodeScannedListener listener)
Scans a QR code and updates the user's profile and the QR code document in the database accordingly.- Parameters:
qrString
- The hash of the QR code to be scanned.username
- The username of the user scanning the QR code.latitude
- The latitude of the user's location when scanning the QR code. Use 181 to skip.longitude
- The longitude of the user's location when scanning the QR code. Use 181 to skip.photoUrl
- The URL of the photo taken by the user when scanning the QR code.points
- The number of points awarded to the user for scanning the QR code.featureList
- An array of 5 numbers used to generated visual representation.listener
- A callback listener to notify when the QR code scan is complete.
-
uploadAndRetrieveDownloadUrl
public void uploadAndRetrieveDownloadUrl(android.net.Uri file, java.lang.String qrString, OnQRCodeUploadListener listener)
Uploads a file to Firebase Storage and retrieves the download URL.- Parameters:
file
- The Uri of the file to be uploaded.qrString
- The unique identifier associated with the QR code to be used as a subdirectory in Firebase Storage.listener
- The OnQRCodeUploadListener that listens for upload success or failure events.
-
deleteUserFromQRCode
public void deleteUserFromQRCode(java.lang.String qrString, java.lang.String username, OnUserDeleteFromQRCodeListener listener)
Deletes a user's username from a QR code's scannedUsers array in the database.- Parameters:
qrString
- The string value of the QR code.username
- The username of the user to be deleted.listener
- The listener to handle the result of the operation.
-
getQRCode
public void getQRCode(java.lang.String qrString, QRCodeListener listener)
Retrieves a QRCode from the Firestore database given a QR string. If the QR string does not match any QRCode in the database, the listener will receive an onQRCodeNotFound() callback. If the QRCode is successfully retrieved, the listener will receive an onQRCodeRetrieved() callback with the retrieved QRCode. If the retrieval process fails, the listener will receive an onQRCodeLoadFailure() callback with the Exception that caused the failure.- Parameters:
qrString
- the QR string to match with a QRCode in the databaselistener
- the listener that will receive the callbacks after the QRCode is retrieved or if there is a failure
-
getScannedUsers
public void getScannedUsers(com.google.firebase.firestore.DocumentSnapshot documentSnapshot, OnScannedUsersLoadedListener listener)
-
getComments
public void getComments(com.google.firebase.firestore.DocumentSnapshot documentSnapshot, OnCommentsLoadedListener listener)
-
getAllQrCoordinates
public void getAllQrCoordinates(OnCoordinatesListLoadedListener listener)
A function that retrieves a list of all qr coordinates.- Parameters:
listener
- The listener to be notified of the result of the function.
-
getQrCodesSortedByPoints
public void getQrCodesSortedByPoints(OnQrListLoadedListener listener)
A function that retrieves a list of qr codes sorted by its points.- Parameters:
listener
- The listener to be notified of the result of the function.
-
-