artistProfileRecyclerView=findViewById(R.id.recyclerViewArtist)
artistProfileRecyclerView.layoutManager=LinearLayoutManager(this@DashBoardActivity)
artistArrayList= arrayListOf()
artistProfileRecyclerView.adapter=ArtistsProfileAdapter(artistArrayList,this@DashBoardActivity)
// Retrofit API call for artist profiles
val retrofitBuilderArtist=Retrofit.Builder()
.baseUrl("https://deezerdevs-deezer.p.rapidapi.com/")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ArtistProfileApiInterface::class.java)
//call the API to get artist data
val retrofitArtistData=retrofitBuilderArtist.getProductData("artist")
retrofitArtistData.enqueue(object :Callback{
override fun onResponse(call : Call, response: Response) {
val artistsProfileDataList=response.body()?.data ?:return
for (artist in artistsProfileDataList){
val artistName=artist.title
val artistImage=artist.album.cover_medium
val artistsProfile=ArtistsProfile(artistName,artistImage)
artistArrayList.add(artistsProfile)
}
artistProfileRecyclerView.adapter?.notifyDataSetChanged()
}
override fun onFailure(call: Call, t: Throwable) {
Log.d("TAG: onFailure", "onFailure: "+t.message)
}
})
Я пытаюсь получить данные dazzer API данных профиля исполнителя:
[img]https:/ /i.sstatic.net/fzxtYcL6.png[/img]
Вызов API из dazzer API для профиля исполнителя, но данные не загружают профиль исполнителя RecyclerView: [code]artistProfileRecyclerView=findViewById(R.id.recyclerViewArtist) artistProfileRecyclerView.layoutManager=LinearLayoutManager(this@DashBoardActivity) artistArrayList= arrayListOf()
// Retrofit API call for artist profiles val retrofitBuilderArtist=Retrofit.Builder() .baseUrl("https://deezerdevs-deezer.p.rapidapi.com/") .addConverterFactory(GsonConverterFactory.create()) .build() .create(ArtistProfileApiInterface::class.java)
//call the API to get artist data
val retrofitArtistData=retrofitBuilderArtist.getProductData("artist")
retrofitArtistData.enqueue(object :Callback{ override fun onResponse(call : Call, response: Response) { val artistsProfileDataList=response.body()?.data ?:return
for (artist in artistsProfileDataList){
val artistName=artist.title val artistImage=artist.album.cover_medium
val artistsProfile=ArtistsProfile(artistName,artistImage) artistArrayList.add(artistsProfile) } artistProfileRecyclerView.adapter?.notifyDataSetChanged() }
override fun onFailure(call: Call, t: Throwable) { Log.d("TAG: onFailure", "onFailure: "+t.message) } }) [/code] Я пытаюсь получить данные dazzer API данных профиля исполнителя: [img]https:/ /i.sstatic.net/fzxtYcL6.png[/img]