Getting this error:
Type mismatch: inferred type is List<BookParkingResponse.Data> but List<BookParkingResponse.Data.ParkingRequests> was expected
unable to pass data bewteeen fragments
Nav Graph code:
navGraph
<argument
android:name="bookingRequestList"
app:argType="com.jvm.di.model.parkingSpot.response.BookParkingResponse.Data" />
Response class
@Parcelize
data class BookParkingResponse(
@SerializedName("data") var data: List<Data>? = null
):Parcelable {
@Parcelize
data class Data(
@SerializedName("parkingRequests") var parkingRequests: List<ParkingRequests>? = null
) : Parcelable {
@Parcelize
data class ParkingRequests(
@SerializedName("parkingSpotId") var parkingSpotId: Int? = null,
@SerializedName("bookingStatus") var bookingStatus: String? = null,
@SerializedName("amount") var amount: Double? = null):Parcelable
}
// pass data on itemClick
findNavController().navigate( MyParkFragmentDirections.toAllRequestListFragment(it))
// how I receive data in another fragments
private val args: AllRequestListFragmentArgs by navArgs()
allRequestListAdapter = AllRequestListAdapter()
rvItems.adapter = allRequestListAdapter
allRequestListAdapter.allParkingRequestList = listOf(args.bookingRequestList)
// how i create list in adapter
internal var allParkingRequestList: List<BookParkingResponse.Data> by Delegates.observable(
emptyList()
) { _, _, _ -> notifyDataSetChanged() }
2
Answers
So, I resolve my issue. corrected navgraph
You should write below code