...
addCommentButton.setOnClickListener {
val
comment = commentEditText.text.toString().trim()
if
(comment.isNotEmpty()) {
cloudFirestoreManager.addComment(
post.id,
comment,
::onCommentSuccessfullyAdded,
::onCommentAddFailed
)
}
else
{
showToast(getString(R.string.empty_comment_message))
}
}
This will save the
comment to the database on
Add Comment
button click.
Build and run your app. Tap on any post in the list. Enter
some text into the
comments
EditText
and
tap the
Add Comment
button:
Your comment is now saved to the database. Open the
database in the console to
confirm that. You should see your comment there:
Saving Data on Android
Chapter 18: Reading Data from Cloud Firestore
raywenderlich.com
266