Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override fun onResume() {
- super.onResume()
- //This is where the function call happens that returns the default values
- var j = doAsyncResult { return@doAsyncResult readData() }.get()
- //This logs "favs"
- d(TAG, j?.Favs)
- }
- fun readData(): databaseManager.UserInfo {
- val auth = FirebaseAuth.getInstance()
- var db = FirebaseFirestore.getInstance()
- var user = UserInfo()
- //this path is correct and works in other functions.
- db.collection("users").document(auth.currentUser!!.uid)
- .get()
- .addOnCompleteListener { task ->
- val data: MutableMap<String, Any?> = task.result?.data!!
- if (data.isNullOrEmpty()) {
- d(TAG, "Document Result is Null or Empty")
- } else {
- d(TAG, "Document is not Empty. Adding to user data class.")
- user.name = data["name"].toString()
- user.email = data["email"].toString()
- user.id = data["id"].toString()
- user.SevenDay = data["sevenDay"].toString()
- user.Favs = data["favs"].toString()
- //This Logs correct Information.
- d(TAG, user.toString())
- }
- }
- return user
- }
- data class UserInfo(
- var name: String? = "name",
- var id: String? = "id",
- var Favs: String? = "favs",
- var SevenDay: String? = "sevenday"
- )
Advertisement
Add Comment
Please, Sign In to add comment