I tried converting my code from java to kotlin and hence I am facing this error. I don't understand why am I getting this error
Error
Smart cast to 'RecyclerView!' is impossible, because 'recentRecycler' is a mutable property that could have been changed by this time
Smart cast to 'RecyclerView!' is impossible, because 'recentRecycler' is a mutable property that could have been changed by this time
Smart cast to 'RecyclerView!' is impossible, because 'topPlacesRecycler' is a mutable property that could have been changed by this time
Smart cast to 'RecyclerView!' is impossible, because 'topPlacesRecycler' is a mutable property that could have been changed by this time
I am only attaching the code which is giving me an error and highlightin it too
private fun setRecentRecycler(recentsDataList: List<RecentsData>) {
recentRecycler = findViewById(R.id.recent_recycler)
val layoutManager: RecyclerView.LayoutManager =
LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
**recentRecycler.setLayoutManager(layoutManager)** //error
recentsAdapter = RecentsAdapter(this, recentsDataList)
**recentRecycler.setAdapter(recentsAdapter)**//error
}
private fun setTopPlacesRecycler(topPlacesDataList: List<TopPlacesData>) {
topPlacesRecycler = findViewById(R.id.top_places_recycler)
val layoutManager: RecyclerView.LayoutManager =
LinearLayoutManager(this, RecyclerView.VERTICAL, false)
**topPlacesRecycler.setLayoutManager(layoutManager)**//error
topPlacesAdapter = TopPlacesAdapter(this, topPlacesDataList)
**topPlacesRecycler.setAdapter(topPlacesAdapter)**//error
}