Tengo este codigo para android kotlin pero me da un error de referencia sin resolver en mContext alguien que sepa cual es el problema
Codigo:
Declaracion de variables y un constuctor
class ChatAdapter : RecyclerView.Adapter <ChatAdapter.MessageViewHolder?> {
private var mMessages: List<Message>? = null
private var mContext: Context? = null
private var mUserId: String? = null
constructor(mContext: Context? , mUserId: String?, mMessages: List<Message>?) : super() {
this.mMessages = mMessages
this.mContext = mContext
this.mUserId = mUserId
}
una nueva clase para el uso de las variables anteriores
class IncomingMessageViewHolder(itemView: View) :
MessageViewHolder(itemView) {
var imageOther: ImageView
var body: TextView
var name: TextView
override fun bindMessage(message: Message? ) {
Glide.with(mContext)
.load(getProfileUrl(message?.getUserId()!!))
.circleCrop() // create an effect of a round profile picture
.into(imageOther);
body.setText(message?.getBody());
name.setText(message?.getUserId());
}
init {
imageOther = itemView.findViewById<View>(R.id.ivProfileOther) as ImageView
body = itemView.findViewById<View>(R.id.tvBody) as TextView
name = itemView.findViewById<View>(R.id.tvName) as TextView
}
}