Skip to content

Commit

Permalink
added null check for username returned from Firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shipitsteven committed May 28, 2021
1 parent 7d36377 commit df89704
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ class FirebaseActivity : AppCompatActivity() {
for (userSnapshot in dataSnapshot.children) {
Log.d("UserSnapshot", userSnapshot.value.toString())
val key = userSnapshot.key
val userNameString = if (userSnapshot.child("username").value != null) {
userSnapshot.child("username").value.toString()
} else {
"N/A"
}
val user = User(
userSnapshot.child("username").value.toString(),
userNameString,
userSnapshot.child("email").value.toString(),
userSnapshot.child("updated").value.toString()
)
Expand Down

0 comments on commit df89704

Please sign in to comment.