76.10 Preparing the Main Fragment
The last remaining component to modify is the MainFragment class which needs to configure listeners on the Button views and observers on the live data objects located in the ViewModel class. Before adding this code, some preparation work needs to be performed to add some imports, variables and to obtain references to view ids. Edit the MainFragment.kt file and modify it as follows:
package com.ebookfrenzy.roomdemo.ui.main
.
.
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ebookfrenzy.roomdemo.Product
import androidx.fragment.app.viewModels
import kotlinx.android.synthetic.main.main_fragment.*
import java.util.*
class MainFragment : Fragment() {
private var adapter: ProductListAdapter? = null
.
.
val viewModel: MainViewModel...