Use Kotlin Android Extensions to Replace findViewById
Kotlin Android Extensions is a great way to avoid writing findViewById in the activity or fragment. Simply, add the kotlin-android-extensions plugin to the module level build.gradle file. apply plugin: 'kotlin-android-extensions' Only one step to enable the feature. Now, we can remove the manual initializations. // Initialize the UI elements val constraintLayout = findViewById<ConstraintLayout>(R.id.coordinatorLayout) val responseTextView = findViewById<TextView>(R.id.responseTextView) val bottomAppBar = findViewById<BottomAppBar>(R.id.bottomAppBar) val fab = findViewById<FloatingActionButton>(R.id.fab) val productRecyclerView = findViewById<RecyclerView>(R.id.productRecyclerView) val filterButton = findViewById<Button>(R.id.filterButton) val sortButton = findViewById<Button>(R.id.sortButton) The compilers suggest us only one import to get all the synthetic properties available in the layout. If the above views are a...