Help with Firebase and Android studio, collect data

Asked

Viewed 29 times

0

Guys I have the following list in the database

Lista Fechada com os uid do usuario

Opening each user of the list I have this information

Informações Abertas

I need to take this information and play for a model class android studio, for this I’m using a foreach using the users node, it returns me the id of users, if I want to take the value it ignores the uid and sends me only the value, so far so good.

but now I want to put it inside my model class that will receive this data so that I can use it in recyclerview that will receive this data from users.

In this case it would be the model class:

class UserInfoModel {
    var nome: String? = null
    var sobrenome: String? = null
    var cPF: String? = null
    var numCR: String? = null
    var telefone: String? = null
    var dataNasc: String? = null
    var nickname: String? = null
    var firstacess: Boolean? = false
    var imgUrl: String? = null
}

I can’t do with arrayList or List or anything, I’ll send you the code of my recyclerview

class ContactsAdapter() : RecyclerView.Adapter<ContactsAdapter.Viewholder>() {

    //Variavel responsavel por pegar o id do usuario atual
    val uid = FirebaseAuth.getInstance().uid.toString()

    //Variavel de referencia ao banco de dados do Firebase
    val verify = FirebaseDatabase.getInstance().reference.child("usuarios")

    var cont = 0

    inner class Viewholder(itemView: View) : RecyclerView.ViewHolder(itemView) {

        val ImageContact = itemView.findViewById<ImageView>(R.id.image_profile_contacts)
        val NameContact = itemView.findViewById<TextView>(R.id.name_contact)
        val statusContact = itemView.findViewById<TextView>(R.id.status_contact)
        val modelcontatos: ContactsInfoModels = ContactsInfoModels()


        init {
            verify.addValueEventListener(object : ValueEventListener{
                override fun onDataChange(snapshot: DataSnapshot) {
                    snapshot.children.forEach{

                    }
                }

                override fun onCancelled(error: DatabaseError) {

                }

            })
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Viewholder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.contacts_view, parent, false)
        return Viewholder(view)
    }

    override fun onBindViewHolder(holder: Viewholder, position: Int) {
    }

    override fun getItemCount() = 1
}

I’ve tried everything and I don’t succeed, my intention with this is to complete a list of contacts in the app where the person can click on one of these contacts and start a conversation.

Esta era para ser a lista de contatos no app

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.