package Ġcom . on ur bar man . mov ied b . ui . main . ui . tv Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . LinearLayout Ċ import Ġandroid . widget . Rating Bar Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . on ur bar man . mov ied b . R Ċ import Ġcom . on ur bar man . mov ied b . util . G lide Utils Ċ import Ġcom . on ur bar man . mov ied b . util . Utils Ċ import Ġcom . on ur bar man . mov ied b . data . model . Cast And Cre w Ċ import Ġcom . on ur bar man . mov ied b . ui . main . ui . Cast And Cre w Adapter Ċ import Ġcom . on ur bar man . mov ied b . ui . main . ui . Cast And Cre w ViewModel Ċ Ċ class ĠTV Detail Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġback drop : ĠImageView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġposter : ĠImageView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtitle : ĠTextView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrating : ĠRating Bar ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġoverview : ĠTextView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġinfo : TextView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġvote First : ĠTextView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġvote Second : ĠTextView ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlinear TV Back Button : ĠLinearLayout ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtv Detail Share Button : ĠImageView ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtv Detail ArrayList Ġ: ĠArrayList < String > ĊĠĠĠ Ġprivate Ġvar Ġrating Score Ġ: ĠDouble Ġ= Ġ 0 . 0 ĊĠĠĠ Ġprivate Ġvar Ġid Ġ: ĠString Ġ= Ġ" 1 " ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcast And Cre w : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcast And Cre w Adapter : ĠCast And Cre w Adapter ĊĊĠĠĠ Ġval ĠviewModel Ġ: ĠCast And Cre w ViewModel Ġby Ġview Models () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ tv _ detail , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġback drop Ġ= Ġview . findViewById ( R . id . image TV Detail Big ) ĊĠĠĠĠĠĠĠ Ġposter Ġ= Ġview . findViewById ( R . id . image TV Detail ) ĊĠĠĠĠĠĠĠ Ġtitle Ġ= Ġview . findViewById ( R . id . text TV Detail Name ) ĊĠĠĠĠĠĠĠ Ġrating Ġ= Ġview . findViewById ( R . id . tv Detail Rating Bar ) ĊĠĠĠĠĠĠĠ Ġoverview Ġ= Ġview . findViewById ( R . id . text TV Detail Description ) ĊĠĠĠĠĠĠĠ Ġinfo Ġ= Ġview . findViewById ( R . id . text TV Detail Info ) ĊĠĠĠĠĠĠĠ Ġvote First Ġ= Ġview . findViewById ( R . id . tv Detail Vote First ) ĊĠĠĠĠĠĠĠ Ġvote Second Ġ= Ġview . findViewById ( R . id . tv Detail Vote Second ) ĊĊĠĠĠĠĠĠĠ Ġtv Detail Share Button Ġ= Ġview . findViewById ( R . id . tv Detail Share Button ) ĊĠĠĠĠĠĠĠ Ġlinear TV Back Button Ġ= Ġview . findViewById ( R . id . linear TV Back Button ) ĊĊĠĠĠĠĠĠĠ Ġtv Detail Share Button . setOnClickListener { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshare Button Click () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġlinear TV Back Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġback Button Click () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcast And Cre w Ġ= Ġview . findViewById ( R . id . re cyclerView TV Full Cast And Cre w ) ĊĊĠĠĠĠĠĠĠ Ġtv Detail ArrayList Ġ= Ġrequire Arguments (). getString ArrayList (" TV Detail ArrayList ") !! ĊĠĠĠĠĠĠĠ Ġrating Score Ġ= Ġrequire Arguments (). getDouble (" T VR ating Score ", 1 . 0 ) ĊĠĠĠĠĠĠĠ Ġid Ġ= Ġrequire Arguments (). getString (" TV Detail Id "," 1 ") ĊĊĠĠĠĠĠĠĠ Ġpopulate Details () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshare Button Click () Ġ{ ĊĠĠĠĠĠĠĠ ĠUtils . share Details ( require Context (), title . text . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġback Button Click () Ġ{ ĊĠĠĠĠĠĠĠ ĠgetParent FragmentManager (). pop Back Stack Immediate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġpopulate Details () Ġ{ ĊĠĠĠĠĠĠĠ Ġtv Detail ArrayList . get ( 1 ). let Ġ{ Ġback drop Path Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠG lide Utils . url To ImageView (" https :// image . t mdb . org / t / p / w 3 4 2 $ backdrop Path ", backdrop , require Context ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġtv Detail ArrayList . get ( 2 ). let Ġ{ Ġposter Path Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠG lide Utils . url To ImageView (" https :// image . t mdb . org / t / p / w 1 5 4 $ poster Path ", poster , require Context ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġtitle . text Ġ= Ġtv Detail ArrayList . get ( 0 ) ĊĠĠĠĠĠĠĠ Ġvote First . text = rating Score . toString (). substring ( 0 , 1 ) ĊĠĠĠĠĠĠĠ Ġvote Second . text = rating Score . toString (). substring ( 1 , 3 ) ĊĠĠĠĠĠĠĠ Ġrating . rating Ġ= Ġ( rating Score / 2 f ). toFloat () ĊĠĠĠĠĠĠĠ Ġoverview . text Ġ= Ġtv Detail ArrayList . get ( 3 ) ĊĠĠĠĠĠĠĠ Ġinfo . text = require Arguments (). getInt (" TV Detail Vote Count ", 1 ). toString () Ġ+" ĠPeople Ġv oted " ĊĊĠĠĠĠĠĠĠ Ġget Cast And Cre w () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Cast And Cre w () ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ Ġcast And Cre w . layout Manager Ġ= ĠLinearLayoutManager ( Ġcontext , ĠLinearLayoutManager . HORIZONTAL , Ġfalse Ġ) ĊĊĊĠĠĠĠĠĠĠ ĠviewModel . getT VC ast And Cre w Observable ( id ) !!. observe ( view Lifecycle Owner , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠObserver < Cast And Cre w > Ġ{ Ġcast And Cre w Data Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( cast And Cre w Data Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcast And Cre w Adapter Ġ= ĠCast And Cre w Adapter ( require Context (), Ġcast And Cre w Data . cast , Ġcast And Cre w Data . cre w ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcast And Cre w . adapter Ġ= Ġcast And Cre w Adapter ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcast And Cre w Adapter . update Cast And Cre w ( cast And Cre w Data . cast , Ġcast And Cre w Data . cre w ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ Ċ }