package Ġso y . gab im ore no . gab in im ble . presentation . main Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . view . Gravity Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroidx . transition . Slide Ċ import Ġorg . k oin . android x . view model . ext . android . viewModel Ċ import Ġso y . gab im ore no . gab in im ble . R Ċ import Ġso y . gab im ore no . gab in im ble . cored omain . Song Ċ import Ġso y . gab im ore no . gab in im ble . databinding . Activity Main Binding Ċ import Ġso y . gab im ore no . gab in im ble . lib base . activity . State less Base Activity Ċ import Ġso y . gab im ore no . gab in im ble . lib framework . extension . exhaustive Ċ import Ġso y . gab im ore no . gab in im ble . lib framework . extension . navigate Adding To Back Stack To Ċ import Ġso y . gab im ore no . gab in im ble . lib framework . extension . navigate To Ċ import Ġso y . gab im ore no . gab in im ble . presentation . main . detail . Main Detail Fragment Ċ import Ġso y . gab im ore no . gab in im ble . presentation . main . list . Main List Fragment Ċ Ċ class ĠMainActivity Ġ: ĠStateless Base Activity < ĊĠĠĠ ĠActivity Main Binding , ĊĠĠĠ ĠMain ViewModel . View Events , ĊĠĠĠ ĠMain ViewModel ĊĠĠĠ Ġ> () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġlaunch ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMainActivity :: class . java ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . startActivity ( intent ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġview Binding : Ġ( LayoutInflater ) Ġ-> ĠActivity Main Binding Ġ= Ġ{ ĊĠĠĠĠĠĠĠ ĠActivity Main Binding . inflate ( it ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval ĠviewModel : ĠMain ViewModel Ġby ĠviewModel () ĊĊĠĠĠ Ġoverride Ġfun Ġon Back Pressed () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( support FragmentManager . back Stack Entry Count Ġ> Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsupport FragmentManager . pop Back Stack () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġsuper . on Back Pressed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinit UI () Ġ{} ĊĊĠĠĠ Ġoverride Ġfun Ġhandle View Event ( view Event : ĠMain ViewModel . View Events ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( view Event ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠMain ViewModel . View Events . Navigate To Main List Ġ-> Ġnavigate To Main List () ĊĠĠĠĠĠĠĠ Ġ}. exhaustive ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġnavigate To Main List () Ġ{ ĊĠĠĠĠĠĠĠ Ġnavigate To ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . fl Container , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMain List Fragment . newInstance ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ:: navigate To Main Detail ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġenter Transition Ġ= ĠSlide ( Gravity . END ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexit Transition Ġ= ĠSlide ( Gravity . START ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġnavigate To Main Detail ( ĊĠĠĠĠĠĠĠ Ġfilename : ĠString , ĊĠĠĠĠĠĠĠ Ġsong : ĠSong ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsong Id Ġ= Ġsong . id ĊĠĠĠĠĠĠĠ Ġnavigate Adding To Back Stack To ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . fl Container , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMain Detail Fragment . newInstance ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfilename , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsong Id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġenter Transition Ġ= ĠSlide ( Gravity . END ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexit Transition Ġ= ĠSlide ( Gravity . START ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ