'mutableListOf() I want to use it globally using lateinit Kotli
private lateinit var participants: mutableListOf<ParticipantDTO>
participants = mutableListOf<ParticipantDTO>()
private fun searchMatchInfoByMatchID(matchId: String,summonerName: String){
lolAPIForMatch.getMatchInfoByMatchID(matchId, API_KEY)
.enqueue(object : Callback<MatchDTO>{
override fun onResponse(call: Call<MatchDTO>, response: Response<MatchDTO>) {
if(response.isSuccessful.not()){
return
}
response.body()?.let {
it.info.participants.filter {
it.summonerName == "${summonerName}"
}.forEach {
participants.add(it)
}
participantAdapter.participants = participants
}
}
override fun onFailure(call: Call<MatchDTO>, t: Throwable) {
}
})
}
participantAdapter.participants = participants
First, declare it as a global variable.
After initialization in onCreate function.
By putting data into participants in the searchMatchInfoByMatchID function
I want to assign participants to participantAdapter.participants, but the data is not being allocated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
