title: Android DataBinding item position in a recyclerView
body: <p>I have a Fragment with a ViewModel (so Mvvm) and in the xml I have 2 RecyclerView with both having their own Adapter using the same itemList because I want to see the same data in 2 different layout.</p>
  
  <p>Before switching to Mvvm, I could reference the adapter and the recyclerView and could reach "getChildAdapterPosition"</p>
  
  <p>But right now this is quite impossible it seem. I made some custom BindingAdapter to bind my Adapter, a CustomPageSnaperHelper and a scrollListener. but now I can't seem to be able to sync the 2 to show the same item even if i scroll the bottom one or the top one.</p>
  
  <p>Gonna post some code snippet, but not sure which one would help more:</p>
  
  <pre><code>@JvmStatic @BindingAdapter("adapter")
  fun &lt;T : RecyclerView.ViewHolder&gt; setRvAdapter(rv: RecyclerView, adapter: RecyclerView.Adapter&lt;T&gt;?) {
      if(adapter != null) rv.adapter = adapter
  }
  
  @JvmStatic @BindingAdapter("pageSnapper")
  fun setPageSnapper(rv: RecyclerView, cs: CustomSnapHelper?){
      cs?.attachToRecyclerView(rv)
  }
  
  @JvmStatic @BindingAdapter("rvScrollListener")
  fun setRvScrollListener(rv: RecyclerView, sl: RecyclerView.OnScrollListener?){
      if (sl == null) return
      rv.addOnScrollListener(sl)
  }
  </code></pre>
  
  <p>Xml:</p>
  
  <pre><code>&lt;androidx.recyclerview.widget.RecyclerView
          adapter="@{vm.OCardAdapter}"
          pageSnapper="@{vm.OCardPageSnaper}"
          rvScrollListener="@{vm.OCardScrollListener}"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@id/top_tabs"
          tools:listItem="@layout/card_layout" /&gt;
  
      &lt;androidx.recyclerview.widget.RecyclerView
          adapter="@{vm.OCarouselAdapter}"
          pageSnapper="@{vm.OCarouselPageSnaper}"
          rvScrollListener="@{vm.OCarouselScrollListener}"
          android:layout_width="wrap_content"
          android:layout_height="200dp"
          android:background="@color/colorWhite"
          android:orientation="horizontal"
          app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          tools:listItem="@layout/carousel_layout"/&gt;
  </code></pre>
  
  <p>To be fair I could paste in more of my code, but I don't think it could help more ish.</p>
  
  <pre><code>val scrollListenerCard = object: RecyclerView.OnScrollListener(){
      var mScrolled = false
      override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
          super.onScrolled(recyclerView, dx, dy)
      }
  
      override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
          super.onScrollStateChanged(recyclerView, newState)
      }
  }
  </code></pre>