I am trying to learn kotlin and I want to convert one of my android projects from java to kotlin. But I have a problem
override fun onResponse(call: Call<List<CitySearch>>?, response: Response<List<CitySearch>>?) {
if(response != null && response.isSuccessful) {
val list = response.body()
cityAdapter.clear()
if(list != null && !list.isEmpty()){
cityAdapter.addAll(list)
listView.visibility = View.VISIBLE
recyclerView.visibility = View.GONE
cityName.visibility = View.GONE
}
}
}
I get the error Operation is not supported for read-only collection at kotlin.collections.EmptyList.clear() on the line with cityAdapter.clear() I don't know how to solve it.
For all the project please check