The following code is the project.
I don't understand fully the code onExploreItemClicked = { launchDetailsActivity(context = this, item = it) } in class MainActivity .
The fun launchDetailsActivity requires two paramaters which are Context and ExploreModel.
One of paramater is Context which is assigned with this, it's OK;
Another of paramater is ExploreModel which is assigned with it, I don't know where the object ExploreModel which is represented with it is created, could you tell me?
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
ProvideWindowInsets {
ProvideImageLoader {
CraneTheme {
MainScreen(
onExploreItemClicked = { launchDetailsActivity(context = this, item = it) }
)
}
}
}
}
}
}
@Composable
fun MainScreen(onExploreItemClicked: OnExploreItemClicked) {
...
}
typealias OnExploreItemClicked = (ExploreModel) -> Unit
fun launchDetailsActivity(context: Context, item: ExploreModel) {
context.startActivity(createDetailsActivityIntent(context, item))
}