Skip to content

Instantly share code, notes, and snippets.

@gastsail
Created March 5, 2020 22:52
Show Gist options
  • Save gastsail/b38f4f3244fc0e01d8e4c58145255080 to your computer and use it in GitHub Desktop.
Save gastsail/b38f4f3244fc0e01d8e4c58145255080 to your computer and use it in GitHub Desktop.
val postListener = object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
// Get Post object and use the values to update the UI
val post = dataSnapshot.getValue(Post::class.java)
// ...
}
override fun onCancelled(databaseError: DatabaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException())
// ...
}
}
postReference.addValueEventListener(postListener)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment