title: RecyclerView not auto scrolling to the top after updating adapter
body: <p>I have a custom adapter, and filter that I am currently implementing to filter a recycler view based on a simple substring search on my recycler view entries. Here is my adapter <code>NotifyChanged()</code> function, which updates the RecylerView, and my custom <code>filter()</code> function. Everything works great, except for the auto scrolling afterwards.</p>
  
  <pre><code>private fun notifyChanged() {
      val result = DiffUtil.calculateDiff(object : DiffUtil.Callback() {
          override fun getOldListSize(): Int {
              return objects.size
          }
  
          override fun getNewListSize(): Int {
              return temp.size
          }
  
          override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
              return this@DiffRecyclerViewAdapter.areItemsTheSame(objects[oldItemPosition], temp[newItemPosition])
          }
  
          override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
              return this@DiffRecyclerViewAdapter.areContentsTheSame(objects[oldItemPosition], temp[newItemPosition])
          }
      })
      objects.clear()
      objects.addAll(temp)
  
      result.dispatchUpdatesTo(this)
  }
  
  
  fun filter(text : String){
  
      val ob = original_objects as ArrayList&lt;Category&gt;
      val filtered_categories = ArrayList&lt;T&gt;() as ArrayList&lt;Category&gt;
  
  
      for (category in ob){
          //val temp_category = category
          val list_of_subcategories = ArrayList&lt;T&gt;() as ArrayList&lt;Category&gt;
          for (subcategory in category.categories){
              val name_of_category = subcategory.name.toLowerCase()
              if (name_of_category.contains(text)){
                  list_of_subcategories?.add(subcategory)
              }
          }
          if (list_of_subcategories.size &gt; 0){
              val newCategory = Category(category.id,category.name,category.description,category.videos,list_of_subcategories)
              filtered_categories.add(newCategory)
          }
      }
      temp = filtered_categories as MutableList&lt;T&gt;
      notifyChanged()
  }
  </code></pre>
  
  <p>In my SearchActivity.kt I have the following listener:</p>
  
  <pre><code>    searchEditText.addTextChangedListener(object : TextWatcher{
          override fun afterTextChanged(s: Editable?) {}
  
          override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
  
          override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
              adapter.filter(s.toString())
              recyclerView.scrollToPosition(0)
          }
  
      })
  </code></pre>
  
  <p>I was looking through the source code of <code>DiffUtil</code> and <code>notifyDataSetChanged()</code> to see how scrolling after filtering works. But didn't have much luck. The whole problem is that after I search text the RecyclerView is filtered fine. But will scroll to inconsistent locations. I want it to scroll back to the top every single time, but this isn't happening. EVEN WITH <code>scrollToPosition(0)</code> it will USUALLY scroll to the top, but not always.</p>
  
  <p>I thought scrolling to the top was typically automatic in this case. I'm curious as to what the best practice is in updating and scrolling. </p>