Here is my code…
package com.example.whatsappclone.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.paging.PagedList
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.whatsappclone.KEY
import com.example.whatsappclone.Models.User
import com.example.whatsappclone.Models.UserViewHolder
import com.firebase.ui.firestore.paging.FirestorePagingAdapter
import com.firebase.ui.firestore.paging.FirestorePagingOptions
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.Query
import kotlinx.android.synthetic.main.fragments_chats.*
class PeopleFragment : Fragment() {
lateinit var mAdapter : FirestorePagingAdapter<User, UserViewHolder>
val auth by lazy{
FirebaseAuth.getInstance()
}
val database by lazy{
FirebaseFirestore.getInstance().collection(KEY)
.orderBy("name", Query.Direction.DESCENDING)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
setUpAdapter()
return super.onCreateView(inflater, container, savedInstanceState)
}
private fun setUpAdapter() {
val config = PagedList.Config.Builder()
.setEnablePlaceholders(false)
.setPrefetchDistance(2)
.setPageSize(10)
.build()
val options = FirestorePagingOptions.Builder<User>()
.setLifecycleOwner(viewLifecycleOwner)
.setQuery(database , config , User::class.java)
.build()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView.apply {
layoutManager = LinearLayoutManager(requireContext())
adapter = mAdapter
}
}
}
this is my error -->
None of the following functions can be called with the arguments supplied:
public open fun setQuery(query: Query, config: PagingConfig, parser: SnapshotParser<User!>): FirestorePagingOptions.Builder<User!> defined in com.firebase.ui.firestore.paging.FirestorePagingOptions.Builder
public open fun setQuery(query: Query, config: PagingConfig, modelClass: Class<User!>): FirestorePagingOptions.Builder<User!> defined in com.firebase.ui.firestore.paging.FirestorePagingOptions.Builder