Kumar
Kumar

Reputation: 979

Android searchview filter in recyclerview pagingDataAdapter with Paging3 is not updating the data

I am trying to search a value from database with the search filter. but not updating the searched values in adapter.

Note: loading the data using Paging3 library.

  private val mDiffer: AsyncListDiffer<Data?> = AsyncListDiffer(this, DataComparator)

 object DataComparator: DiffUtil.ItemCallback<Data>() {
        override fun areItemsTheSame(oldItem: Data, newItem: Data): Boolean {
          
            return oldItem.mobileNo == newItem.mobileNo
        }

        override fun areContentsTheSame(oldItem: Data, newItem: Data): Boolean {
            return oldItem == newItem
        }
    }


    fun submitList(list: List<Data?>?)
    {
        mDiffer.submitList(list)

    }
 override fun publishResults(charSequence: CharSequence?, filterResults: FilterResults)
            {
                submitList(filterResults.values as MutableList<Data>)
              

              
                if (filterResults.count > 0) {
                    notifyDataSetChanged();
                }

            }

iam getting the searched values in inmDiffer.submitList(list) method. but values are not added in adapter.

kindly help me to achieve this.

links referred https://howtodoandroid.com/pagination-with-paging-3-android/
link 2 thanks in advance

Upvotes: 2

Views: 659

Answers (0)

Related Questions