title: How can i filter Adapter Arraylist using Coroutines?
body: <p>In my Fragment I'm using a Recycler View with multiple item types where i want to filter my parent array list based on some conditions and transfer its child list to child recycler view. I am able to filter parent recycler view on main thread but i am worried if the parent array list has thousands of data and performing filtration  on main thread might be not good. So i want to filter my array list using coroutines. This is how i tried it using coroutines.</p>
  <p><strong>MainFragmentAdapter</strong></p>
  <pre><code> override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
    when (position) {
      1 -&gt; {
              val goldAdapter = GoldAdapter()
               var filterGold = methodCallBack.filterData(gold,&quot;gold&quot;)
               if (filterGold.isNotEmpty())
               goldAdapter.goldList = filterGold
               if (mRate.isNotEmpty())
               goldAdapter.goldRate = mRate[0].value!!
              holder.itemView.diamond_text.text = &quot;Gold&quot;
              holder.itemView.diamond_recycler.apply {
                  setHasFixedSize(true)
                  adapter = goldAdapter
              }
              holder.itemView.view_more_button.setOnClickListener {
                  methodCallBack.click(gold)
              }
              goldAdapter.setListener(myContext)
          }
  </code></pre>
  <p><strong>MainFragment</strong></p>
  <pre><code> override fun filterData(myList: MutableList&lt;Item&gt;,type : String) {
       mainFragmentViewModel.viewModelScope.launch {
          mainFragmentViewModel.myFilter(myList,type)
      }
  }
  </code></pre>
  <p><strong>MainFragmentViewModel</strong></p>
  <pre><code>  private val filterGoldList = MutableLiveData&lt;MutableList&lt;Item&gt;&gt;()
    val _filterGold : LiveData&lt;MutableList&lt;Item&gt;&gt;
    get() = filterGoldList
  
      suspend fun myFilter(myList : MutableList&lt;Item&gt;,type : String) =
          withContext(Dispatchers.IO){
                myList.filter { it.isMainPageItem == true }
                      .let {
                            when(type){
                                  &quot;Gold&quot; -&gt; filterGoldList.postValue(it as MutableList&lt;Item&gt;)
                                  &quot;Silver&quot; -&gt; filterSilverList.postValue(it as MutableList&lt;Item&gt;)
                            }
                      }
          }
  </code></pre>
  <p>I am not able to return data back to adapter class.Is there any way to observe live data in adapter class?. Please help me to achieve it..</p>