title: FirestoreRecyclerAdapter with Custom onItemClicked Implementation throws IndexOutOfBoundsException
body: <p>I'm trying to have a FirestoreRecyclerAdapter update a list of chats in an Activity without needing to restart the Activity then allow the user to click on an item in the list and use specific information gathered using the clicked index to start an Activity where the user can chat.</p>
  <p>My custom onItemClicked implementation works fine and everything works as intended if the activity is reloaded; if the user is already in the Activity and the FirestoreRecyclerAdapter dynamically updates without the activity restarting clicking on the new item causes an IndexOutOfBoundsException to be thrown.</p>
  <p>My adapter.</p>
  <pre class="lang-kotlin prettyprint-override"><code>class ChatListAdapter(options: FirestoreRecyclerOptions&lt;UserProfile&gt;
      ) : FirestoreRecyclerAdapter&lt;UserProfile, ChatListAdapter.UserHolder&gt;(options) {
      private var clickListener: ClickListener? = null
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChatListAdapter.UserHolder {
          val view = LayoutInflater.from(parent.context).inflate(
              android.R.layout.simple_list_item_1,
              parent, false
          )
          return UserHolder(view)
      }
  
      override fun onBindViewHolder(holder: UserHolder, position: Int, model: UserProfile) {
          val user: UserProfile = getItem(position)
          holder.itemView.setOnClickListener {
              clickListener!!.onItemClicked(position)
          }
          holder.bind(user)
      }
  
      inner class UserHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
          private var userNameText: TextView
  
          init {
              userNameText = itemView.findViewById&lt;View&gt;(android.R.id.text1) as TextView
          }
  
          fun bind(user: UserProfile) {
              userNameText.text = user.userName
          }
      }
  
      fun setOnItemClickListener(clickListener: ClickListener) {
          this.clickListener = clickListener
      }
  
      interface ClickListener {
          fun onItemClicked(position: Int)
      }
  }
  </code></pre>
  <p>Relevant snippet of code in my Activity.</p>
  <pre class="lang-kotlin prettyprint-override"><code>val query = fsDb.collection(&quot;groups&quot;)
      .document(userId!!).collection(&quot;userGroups&quot;)
  val options = FirestoreRecyclerOptions.Builder&lt;UserProfile&gt;()
      .setQuery(query, UserProfile::class.java).build()
  
  chatListAdapter = ChatListAdapter(options)
  chatsRecyclerView.layoutManager = LinearLayoutManager(this)
  // The RecyclerView itemAnimator needs to be set to null otherwise it
  // will throw an out of bounds exception
  chatsRecyclerView.itemAnimator = null
  chatListAdapter!!.startListening()
  chatsRecyclerView.adapter = chatListAdapter
  
  val uIRef = fsDb.collection(&quot;users&quot;).document(userId!!)
  uIRef.get().addOnCompleteListener {
      if (it.isSuccessful) {
          val doc = it.result
          if (doc.exists()) {
              val fromUser = doc.toObject(UserProfile::class.java)!!
  
              val groupsRef = fsDb.collection(&quot;groups&quot;).document(fromUser.uId)
                  .collection(&quot;userGroups&quot;)
  
              groupsRef.get().addOnCompleteListener { p -&gt;
                  if (p.isSuccessful) {
                      val currentChatNames = ArrayList&lt;String&gt;()
                      val userList = ArrayList&lt;UserProfile&gt;()
                      val groupsList = ArrayList&lt;String&gt;()
                      for (i in p.result) {
                          val contact = i.toObject(UserProfile::class.java)
                          if (contact.uId != fromUser.uId) {
                              currentChatNames.add(contact.userName)
                              userList.add(contact)
                              // Document id works as the group id
                              groupsList.add(i.id)
                          }
                       }
                              
                       chatListAdapter!!.setOnItemClickListener(object : 
                           ChatListAdapter.ClickListener {
                           override fun onItemClicked(position: Int) {
                               val intent = Intent(this@ChatListActivity, 
                                   ChatActivity::class.java)
                               intent.putExtra(&quot;fromUser&quot;, fromUser)
                               intent.putExtra(&quot;toUser&quot;, userList[position])
                               intent.putExtra(&quot;roomId&quot;, groupsList[position])
                               startActivity(intent)
                           }
                       })
  
                  } else {
                      println(&quot;Getting list of current chats was unsuccessful&quot;)
                  }
              }
          }
      }
  }
  </code></pre>