package Ġcom . example . ron ens ab ag . mult im odule child fragment Ċ Ċ import Ġandroid . arch . lifecycle . ViewModel Providers Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġdagger . android . Dispatch ing Android Injector Ċ import Ġdagger . android . support . Android Support Injection Ċ import Ġdagger . android . support . Has Support Fragment Injector Ċ import Ġkotlinx . android . synt hetic . main . fragment _ host . fab Ċ import Ġkotlinx . android . synt hetic . main . fragment _ host . host Container Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠHost Fragment Ġ: ĠFragment (), ĠHas Support Fragment Injector Ġ{ ĊĊĠ Ġ@ Inject Ġlateinit Ġvar Ġpresenter : ĠHost Presenter ĊĠ Ġ@ Inject Ġlateinit Ġvar Ġfragment Injector : ĠDispatch ing Android Injector < Fragment > ĊĊĠ Ġoverride Ġfun Ġsupport Fragment Injector () Ġ= Ġfragment Injector ĊĊĠ Ġoverride Ġfun Ġon Attach ( context : ĠContext ?) Ġ{ ĊĠĠĠ ĠAndroid Support Injection . inject ( this ) ĊĠĠĠ Ġsuper . on Attach ( context ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ host , Ġcontainer , Ġfalse ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠ Ġpresenter . observe Show Fragment Events ( lifecycle ) Ġ{ ĊĠĠĠĠĠ Ġwhen Ġ( it ) Ġ{ ĊĠĠĠĠĠĠĠ ĠShow Parent Fragment State Ġ-> Ġshow First Parent Fragment () ĊĠĠĠĠĠĠĠ ĠShow Child Fragment State Ġ-> Ġshow First Child Fragment () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġfab . setOnClickListener Ġ{ ĊĠĠĠĠĠ Ġpresenter . button Clicked () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġshow First Parent Fragment () Ġ{ ĊĠĠĠ Ġchild FragmentManager ĊĠĠĠĠĠĠĠ Ġ. beginTransaction () ĊĠĠĠĠĠĠĠ Ġ. add ( R . id . host Container , ĠFirst Parent Fragment (), ĠFirst Parent Fragment :: class . java . simple Name ) ĊĠĠĠĠĠĠĠ Ġ. commit () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġshow First Child Fragment () Ġ{ ĊĠĠĠ ĠstartActivity ( Intent ( context , ĠMain 2 Activity :: class . java )) Ċ // ĠĠĠ Ġchild FragmentManager Ċ // ĠĠĠĠĠĠĠ Ġ. beginTransaction () Ċ // ĠĠĠĠĠĠĠ Ġ. add ( R . id . host Container , ĠFirst Child Fragment (), ĠFirst Child Fragment :: class . java . simple Name ) Ċ // ĠĠĠĠĠĠĠ Ġ. commit () ĊĠ Ġ} Ċ } ĊĊ