package Ġcom . mov ied b . discover . view Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . lifecycle . lifecycle Scope Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġcom . mov ied b . core . data . Data Wrapper Ċ import Ġcom . mov ied b . core . di . Injectable Ċ import Ġcom . mov ied b . core . di . inject ViewModel Ċ import Ġcom . mov ied b . core . navigation . Navigation Ċ import Ġcom . mov ied b . core . view . Base ViewModel Fragment Ċ import Ġcom . mov ied b . discover . R Ċ import Ġcom . mov ied b . discover . databinding . Fragment Discover Binding Ċ import Ġcom . mov ied b . discover . view . adapters . Discover Movie Adapter Ċ import Ġcom . mov ied b . discover . view model . Discover ViewModel Ċ import Ġcom . mov ied b . style kit . ui . Grid Item Decoration Ċ import Ġcom . mov ied b . style kit . ui . hide Ċ import Ġcom . mov ied b . style kit . ui . show Ċ import Ġkotlinx . coroutines . flow . collect Latest Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠDis cover Fragment Ġ: ĠBase ViewModel Fragment < Fragment Discover Binding , ĠDis cover ViewModel >(), ĠDis cover Movie Adapter . Discover Movie ClickListener ĊĠĠĠĠĠĠĠ Ġ, ĠInjectable Ġ{ ĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Provider . Factory ĊĊĠĠĠ Ġoverride Ġfun Ġget Layout (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠR . layout . fragment _ discover ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinit View () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= Ġinject ViewModel ( viewModel Factory ) ĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= Ġthis ĊĠĠĠĠĠĠĠ Ġbinding . vm Ġ= ĠviewModel ĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= ĠDis cover Movie Adapter ( this ) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . set Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . layout Manager Ġ= ĠGrid LayoutManager ( context , Ġ 2 ) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . addItem Decoration ( Grid Item Decoration ( 0 , Ġ 2 )) ĊĠĠĠĠĠĠĠ Ġbinding . re cyclerView . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġsubscribe Ui ( binding , Ġadapter ) ĊĠĠĠĠĠĠĠ Ġset Has Options Menu ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġnavigate To ( page Name : ĠString , Ġbundle : ĠBundle ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( page Name ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . Screen Name . MOV IE _ DETAILS Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . action _ nav _ details , Ġbundle ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsubscribe Ui ( binding : ĠFragment Discover Binding , Ġadapter : ĠDis cover Movie Adapter ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlifecycle Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . get Movies (). collect Latest Ġ{ Ġpaging Data Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . progress Bar . hide () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . submit Data ( paging Data ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Discover Movie Clicked ( item : ĠBundle ) Ġ{ ĊĠĠĠĠĠĠĠ Ġnavigate To ( Navigation . Screen Name . MOV IE _ DETAILS , Ġitem ) ĊĠĠĠ Ġ} Ċ } Ċ