title: When I use search filter Recycler View gives wrong Position
body: <p>I have implemented my <code>CustomAdapter.kt</code> with <code>search filter</code> as follows.</p>
  <pre><code>class CustomAdapter(public val context: Context, private val countriesResponse: CountriesResponse) :
  RecyclerView.Adapter&lt;CustomAdapter.MyViewHolder&gt;(), Filterable {
  
  var countryFilterList = CountriesResponse()
  
  init {
      countryFilterList = countriesResponse
  }
  
  
  class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
  
      var image: ImageView
      var cv_tv_country_name: TextView
  
      init {
          
          image = itemView.findViewById(R.id.cv_iv_country_flag)
          cv_tv_country_name = itemView.cv_tv_country_name
  
      }
  }
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
      var itemView = LayoutInflater.from(context).inflate(R.layout.flag_list, parent, false)
      return MyViewHolder(itemView)
  }
  
  override fun getItemCount(): Int {
      return countryFilterList.size
  }
  
  override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
      Glide.with(context).load(countryFilterList[position].countryInfo.flag).into(holder.image)
      
      //Here I am setting onClickListener for the items clicked on recycler view
      
      holder.itemView.setOnClickListener {
           
          //With the help of intent I am starting new activity with taking the position of that item
          
          val intent =
              Intent(context, CountryWiseDataActivity::class.java).putExtra(&quot;position&quot;, position)
          context.startActivity(intent)
      }
      holder.cv_tv_country_name.text = countryFilterList[position].country
  }
  
  override fun getItemId(position: Int): Long {
      return position.toLong()
  }
  
  override fun getFilter(): Filter {
      return object : Filter(){
          override fun performFiltering(constraint: CharSequence?): FilterResults {
              val charSearch = constraint.toString()
              if (charSearch.isEmpty()){
                  countryFilterList = countriesResponse
              } else {
                  val resultList = CountriesResponse()
                  for (row in countriesResponse){
                      if (row.country.toLowerCase(Locale.ROOT).contains(charSearch.toLowerCase(
                              Locale.ROOT))){
                          resultList.add(row)
                      }
                  }
                  countryFilterList = resultList
              }
              val filterResults = FilterResults()
              filterResults.values = countryFilterList
              return filterResults
          }
          @Suppress(&quot;UNCHECKED_CAST&quot;)
          override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
              countryFilterList = results?.values as CountriesResponse
              notifyDataSetChanged()
          }
  
      }
  }
  </code></pre>
  <p>}</p>
  <p>In my Activity I have implemented below for search Filter.</p>
  <pre><code>search_countries.setOnQueryTextListener(object : SearchView.OnQueryTextListener,
          androidx.appcompat.widget.SearchView.OnQueryTextListener {
          override fun onQueryTextSubmit(query: String?): Boolean {
              return false
          }
  
          override fun onQueryTextChange(newText: String?): Boolean {
              countryAdapter.filter.filter(newText)
              return false
          }
      })
  </code></pre>
  <p>This above code works fine and it search the countries as well properly. But when I click the country it should open an another activity <code>CountryWiseDataActivity</code>for that same country.</p>
  <p>I have implemented <code>CountryWiseDataActivity.kt</code> as follows.</p>
  <pre><code>class CountryWiseDataActivity : AppCompatActivity(){
  
  private lateinit var viewModel: CountriesViewModel
  private lateinit var countryDetailsRepository: CountryDetailsRepository
  
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_country_wise_data)
  
      val apiService: ApiService = ApiClient.getClient()
      countryDetailsRepository = CountryDetailsRepository(apiService)
  
      viewModel = getViewModel()
      val intent = getIntent()
      val position = intent.getIntExtra(&quot;position&quot;, 0)//{&lt;- The position of every country with the help of intent
  
      viewModel.countryDetails.observe(this, Observer {
              tv_country.text = it.get(position).country
              tv_country_cases.text = it.get(position).cases.toString()
              tv_country_active.text = it.get(position).active.toString()
              tv_country_critical.text = it.get(position).critical.toString()
              tv_country_recovered.text = it.get(position).recovered.toString()
              tv_country_today_cases.text = it.get(position).todayCases.toString()
              tv_country_today_deaths.text = it.get(position).todayDeaths.toString()
              tv_country_total_deaths.text = it.get(position).deaths.toString()
      })
  }
  
  private fun getViewModel(): CountriesViewModel {
      return ViewModelProviders.of(this, object : ViewModelProvider.Factory {
          override fun &lt;T : ViewModel?&gt; create(modelClass: Class&lt;T&gt;): T {
              return CountriesViewModel(countryDetailsRepository) as T
          }
      })[CountriesViewModel::class.java]
  
  }
  }
  </code></pre>
  <p>But When I search the country in search bar and click on country, then the data displays is only for the <code>position 0</code>. If I don't use search bar for searching countries and simply click on the country for data it gives correct data for every position.</p>
  <p>I am stuck here that how to correct this code, so that I can search countries &amp; on clicking it gives the correct data of that particular country?</p>