We have to use a companion object to instantiate a fragment. Remember we have to use the newInstance() method to initialize a fragment because we cannot use the parameterized constructor for fragments. Our UserTimeLineFragment and HomeTimeLineFragment uses a companion object to help the fragment instantiation:
class UserTimeLineFragment : TwitterFragment() { override fun loadTimeline() { // Code goes here } companion object { /** * Use this factory method to create a new instance of * this fragment using the provided parameters. * * @return A new instance of fragment TwitterFragment. */ fun newInstance(): UserTimeLineFragment = UserTimeLineFragment() } }