title: Trying to set a listener for Firebase chat messages
body: <p>I am trying to set a listener for Firebase to get new chat messages and send them to a recycler view in a fragment, but I keep getting two errors:</p>
  
  <p>The first error is on "Data" in setupAdapter and the second error is on message.timestamp.</p>
  
  <p>Type Mismatch:</p>
  
  <pre><code>Required:
  kotlin.collections.ArrayList&lt;com.ntx_deisgns.cyberchatter.cyberchatter.Message&gt; /* = java.util.ArrayList&lt;com.ntx_deisgns.cyberchatter.cyberchatter.Message&gt; */
  Found:
  kotlin.collections.ArrayList&lt;android.os.Message&gt; /* = java.util.ArrayList&lt;android.os.Message&gt; */
  </code></pre>
  
  <p>And </p>
  
  <pre><code>Unresolved reference: timestamp
  </code></pre>
  
  <p>Here's the code in my fragment class:</p>
  
  <pre><code>private fun createFirebaseListener(){
          val postListener = object : ValueEventListener {
              override fun onDataChange(dataSnapshot: DataSnapshot) {
  
                  val toReturn: ArrayList&lt;Message&gt; = ArrayList();
  
                  for(data in dataSnapshot.children){
                      val messageData = data.getValue&lt;Message&gt;(Message::class.java)
  
                      //unwrap
                      val message = messageData?.let { it } ?: continue
  
                      toReturn.add(message)
                  }
  
                  //sort so newest at bottom
                  toReturn.sortBy { message -&gt;
                      message.timestamp
                  }
  
                  setupAdapter(toReturn)
              }
  
              override fun onCancelled(databaseError: DatabaseError) {
                  //log error
              }
          }
          val database = FirebaseDatabase.getInstance()
          val myRef = database.getReference("message")
          val mDatabase: DatabaseReference? = myRef
  
          mDatabase?.child("Group Chat")?.addValueEventListener(postListener)
      }
  
      /**
       * Once data is here - display it
       */
      private fun setupAdapter(data: ArrayList&lt;Message&gt;){
          val linearLayoutManager = LinearLayoutManager(context)
          viewManager = LinearLayoutManager(context)
          viewAdapter = MessageAdapter(data) {
  //            Toast.makeText(this, "${it.text} clicked", Toast.LENGTH_SHORT).show()
          }
  
          //scroll to bottom
          mainActivityRecyclerView.scrollToPosition(data.size - 1)
      }
  </code></pre>
  
  <p>I have created a class called Message.kt and that is where it is trying to pull from.  Here is that code as well just in case:</p>
  
  <p>package com.ntx_deisgns.cyberchatter.cyberchatter</p>
  
  <pre><code>class Message {
  
      constructor() //empty for firebase
  
      constructor(messageText: String){
          text = messageText
      }
      var text: String? = null
      var timestamp: Long = System.currentTimeMillis()
  }
  </code></pre>
  
  <p>I thought would be a fairly simple and straightforward task but it is turning out not a simple as I was thinking.  What exactly am I missing here that is preventing me from doing this correctly?</p>