Paging 3 android studio kotlin

  android, android-mvvm, dagger-hilt, kotlin
  1. Model class

data class GetNotification(
@SerializedName("data")
val data: MutableList,
@SerializedName("_pagination")
val pagination: Pagination,
@SerializedName("status")
val status: Boolean,
@SerializedName("message")
val message: String,
@SerializedName("status_code")
val statusCode: Int
) {
data class Data(
@SerializedName("booking_id")
val bookingId: String,
@SerializedName("company_id")
val companyId: String,
@SerializedName("created_on")
val createdOn: String,
@SerializedName("description")
val description: String,
@SerializedName("id")
val id: String,
@SerializedName("image")
val image: String,
@SerializedName("title")
val title: String,
@SerializedName("type")
val type: String
)

data class Pagination(
    @SerializedName("currentPage")
    val currentPage: Int,
    @SerializedName("itemCount")
    val itemCount: Int,
    @SerializedName("perPage")
    val perPage: Int,
    @SerializedName("totalItemCount")
    val totalItemCount: Int,
    @SerializedName("totalPageCount")
    val totalPageCount: Int
)

}

class NotificationDataSource(private val token: String, private val apiService: ApiService) :
PagingSource<Int, GetNotification.Data>() {
override suspend fun load(params: LoadParams): LoadResult<Int, GetNotification.Data> {

//This class only return GetNotification.Data

}

notificationViewModel.getNotification("${resources.getString(R.string.bearer)} ${PreferenceHelper.authToken}")
.observe(
viewLifecycleOwner, Observer {
lifecycleScope.launch {
nAdapter.submitData(it)
}
}
)

  1. I am getting result only Data response in main activity but I want to full result.

Like – status, messages

return

}

Source: Android Questions

LEAVE A COMMENT