package Ġcom . b int ang . mv vm . ui . details . movie Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . app . Activity Options Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . MenuItem Ċ import Ġandroid . view . View Ċ import Ġandroidx . lifecycle . observe Ċ import Ġcom . b int ang . common _ ui . extensions . apply Material Transform Ċ import Ġcom . b int ang . common _ ui . extensions . toast Ċ import Ġcom . b int ang . entity . entities . Movie Ċ import Ġcom . b int ang . mv vm . R Ċ import Ġcom . b int ang . mv vm . base . ViewModel Activity Ċ import Ġcom . b int ang . mv vm . databinding . Activity Movie Detail Binding Ċ Ċ class ĠMovie Detail Activity Ġ: ĠViewModel Activity () Ġ{ ĊĊĠ Ġprivate Ġval Ġvm : ĠMovie Detail ViewModel Ġby Ġinject ViewModels () ĊĠ Ġprivate Ġval Ġbinding : ĠActivity Movie Detail Binding Ġby Ġbinding ( R . layout . activity _ movie _ detail ) ĊĊĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠ Ġ// Ġpost Ġthe Ġmovie Ġid Ġfrom Ġintent ĊĠĠĠ Ġvm . post Movie Id ( intent . getInt Extra ( movie Key , Ġ 0 )) ĊĊĠĠĠ Ġ// Ġapply Ġmaterial Ġcontainer Ġtransform ĊĠĠĠ Ġapply Material Transform ( vm . get Movie (). title ) ĊĊĠĠĠ Ġ// Ġbinding Ġdata Ġinto Ġlayout Ġview ĊĠĠĠ Ġwith ( binding ) Ġ{ ĊĠĠĠĠĠ Ġlifecycle Owner Ġ= Ġthis @ Movie Detail Activity ĊĠĠĠĠĠ Ġactivity Ġ= Ġthis @ Movie Detail Activity ĊĠĠĠĠĠ ĠviewModel Ġ= Ġvm ĊĠĠĠĠĠ Ġmovie Ġ= Ġvm . get Movie () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġobserve Ġerror Ġmessages ĊĠĠĠ Ġobserve Messages () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Options ItemSelected ( item : ĠMenuItem ?): ĠBoolean Ġ{ ĊĠĠĠ Ġif Ġ( item ?. itemId Ġ== Ġandroid . R . id . home ) Ġon Back Pressed () ĊĠĠĠ Ġreturn Ġfalse ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġobserve Messages () Ġ= ĊĠĠĠ Ġthis . vm . toast LiveData . observe ( this ) Ġ{ Ġtoast ( it ) Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval Ġmovie Key Ġ= Ġ" movie " ĊĠĠĠ Ġfun ĠstartActivity Model ( context : ĠContext ?, Ġstart View : ĠView , Ġmovie : ĠMovie ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( context Ġis ĠActivity ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( context , ĠMovie Detail Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . putExtra ( movie Key , Ġmovie . id ) ĊĠĠĠĠĠĠĠ Ġval Ġoptions Ġ= ĠActivity Options . make Scene Transition Animation ( context , ĊĠĠĠĠĠĠĠĠĠ Ġstart View , Ġmovie . title ) ĊĠĠĠĠĠĠĠ Ġcontext . startActivity ( intent , Ġoptions . to Bundle ()) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ