FirebaseHelper

class FirebaseHelper

Class containing helper attributes and methods for accessing Firebase.

Constructors

FirebaseHelper
Link copied to clipboard
fun FirebaseHelper(context: Context)
Creates a FirebaseHelper object given the context with which the database is accessed.
FirebaseHelper
Link copied to clipboard
fun FirebaseHelper(context: Context, postId: String?, userIdPost: String?)
Creates a FirebaseHelper object given the context with which the database is accessed, the unique identifier of a post, and the unique identifier of the user who posted it.
FirebaseHelper
Link copied to clipboard
fun FirebaseHelper(context: Context, Id: String?)
Creates a FirebaseHelper object given the context with which the database is accessed and a unique identifier of a database document.

Properties

context
Link copied to clipboard
private var context: Context
Context with which the database is being accessed.
credential
Link copied to clipboard
private lateinit var credential: AuthCredential
Credential used by Firebase to authenticate a user.
db
Link copied to clipboard
private var db: DatabaseReference
Starting point for all database-related operations.
mAuth
Link copied to clipboard
private var mAuth: FirebaseAuth
Starting point for Firebase authentication SDK.
user
Link copied to clipboard
private lateinit var user: FirebaseUser
Represents a user profile's information in the Firebase user database.
userId
Link copied to clipboard
private lateinit var userId: String
Unique identifier of the user.

Functions

deleteCommentDB
Link copied to clipboard
fun deleteCommentDB(commentId: String, postId: String)
Deletes a comment from the database.
deleteCommentFromPostDB
Link copied to clipboard
fun deleteCommentFromPostDB(postId: String)
Deletes a comment from the database.
deletePostANDUserFollowedFromUsersDB
Link copied to clipboard
fun deletePostANDUserFollowedFromUsersDB(postId: String, delUserFF: Boolean)
Deletes a post and its related data (i.e., bookmark, highlight, and upvote status) from the database.
deletePostDB
Link copied to clipboard
fun deletePostDB(postKey: String, delUserFF: Boolean)
Deletes a post from the database.
deleteUser
Link copied to clipboard
fun deleteUser()
Deletes the account details of the current user.
editComment
Link copied to clipboard
fun editComment(commentId: String, commentBody: String)
Edits the body of a comment.
editPost
Link copied to clipboard
fun editPost(postId: String, title: String, medium: String, dimensions: String, desc: String, tags: ArrayList<String>)
Edits the details of a post.
updateBookmarkDB
Link copied to clipboard
fun updateBookmarkDB(userVal: String?, postKey: String?, postVal: String?)
Updates the bookmark status of a post on the database.
updateCommentFromPostDB
Link copied to clipboard
fun updateCommentFromPostDB(postId: String, commentKey: String?, commentVal: String?, numComments: Int)
Updates a comment on the database.
updateHighlightDB
Link copied to clipboard
fun updateHighlightDB(postKey: String?, postVal: String?)
Updates the highlight status of a post on the database.
updateUpvoteDB
Link copied to clipboard
fun updateUpvoteDB(userVal: String?, postKey: String?, postVal: String?, numUpvotes: Int)
Updates the upvotes of a post on the database.
updateUserPostDB
Link copied to clipboard
fun updateUserPostDB(postKey: String, postVal: String?)
Updates the user's list of posts on the database.
updateUsersFollowedDB
Link copied to clipboard
fun updateUsersFollowedDB(userKey: String?, userVal: String?)
Updates the user's list of followed users on the database.