title: How to interact with Viewmodel inside recyclerview adapter?
body: <p>I have seen similar question but it did not help me. I would try to be specific about my problem. I have product list in my shopping cart. when I am searching products I want button &quot;Add to cart&quot; disabled for the item which is already present in cart.</p>
  <p>Cart item list is inside my view model.</p>
  <p>I approached as follows -
  When onBindViewHolder is called for a specific position, i need to search if the current item (product) is present in the list of item present in cart, if it is present then disable Button.</p>
  <p>Here my problem is that Cart is in Viewmodel and i find myself unable to call viewmodel from OnBindViewholder method.</p>
  <p>Is there any better way to do this?</p>
  <pre><code>@Override
  public void onBindViewHolder(@NonNull ProductAdapter.OurViewHolder viewHolder, int i) {
      Products currentItem = adapterData.get(i);
      viewHolder.productNamesFragmentItemsBinding.setProductName(currentItem);
      if (currentItem.getPhotoUris() != null) {
      Picasso.get().load(currentItem.getPhotoUris().get(0)).into(viewHolder.productNamesFragmentItemsBinding.ivProductImage);
  
      //  now i want to search if current item is present in cart (cart is in viewModel), if item
          // is present in cart then disable &quot;Add to Cart&quot; button for current position
          
          //--------------todo : how to do it ??? -----------------------------------
      }
  }
  </code></pre>