Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save francislainy/3453d57aed4029de5c0de2f4f9239af8 to your computer and use it in GitHub Desktop.
Save francislainy/3453d57aed4029de5c0de2f4f9239af8 to your computer and use it in GitHub Desktop.
dataSnapshot.children.forEach {
val answer = it.child("cardAnswer").value as String
val question = it.child("cardQuestion").value as String
val courseId = it.child("courseId").value as String
val cardDs = it.value //map
val json = Gson().toJson(cardDs)
val card = Gson().fromJson<Card>(json, Card::class.java)
// card.cardAnswer = answer
// card.cardQuestion = question
// card.courseId = courseId
adapter.add(CardItem(card))
}
data class Card(var courseId: String, var cardQuestion: String, var cardAnswer: String) {
constructor() : this("", "", "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment