package Ġcom . hello has an . room _ orm . ui . subject . subject _ list Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . hello has an . room _ orm . core . Base Activity Ċ import Ġcom . hello has an . room _ orm . data . repository . subject . Subject Ċ import Ġcom . hello has an . room _ orm . data . repository . subject . Subject Repository Impl Ċ import Ġcom . hello has an . room _ orm . databinding . Activity Subject List Binding Ċ import Ġcom . hello has an . room _ orm . ui . subject . Subject ViewModel Ċ import Ġcom . hello has an . room _ orm . ui . subject . Subject ViewModel Factory Ċ import Ġcom . hello has an . room _ orm . utils . ST UD ENT _ REGISTR ATION Ċ Ċ class ĠSubject List Activity Ġ: ĠBase Activity () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding Ġ: ĠActivity Subject List Binding ĊĠĠĠ Ġprivate Ġvar Ġstudent Registration Number : ĠLong Ġ= Ġ- 1 ĊĊĠĠĠ Ġprivate Ġval Ġrepository Ġby Ġlazy Ġ{ ĠSubject Repository Impl ( application Context ) Ġ} ĊĠĠĠ Ġprivate Ġval ĠviewModel Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= ĠSubject ViewModel Factory ( repository ) ĊĠĠĠĠĠĠĠ ĠViewModel Provider ( this , Ġfactory ). get ( Subject ViewModel :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠActivity Subject List Binding . inflate ( layout Inflater ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( binding . root ) ĊĊĠĠĠĠĠĠĠ Ġstudent Registration Number Ġ= Ġintent . extras ?. getLong ( ST UD ENT _ REGISTR ATION ) Ġ?: Ġ- 1 ĊĊĠĠĠĠĠĠĠ Ġbinding . btn Add Subject . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Subject () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . subject Creation Success LiveData . observe ( this , Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Toast (" Successfully Ġsubject Ġis Ġcreated ") ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . subject Creation Failed LiveData . observe ( this , Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Toast ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Subject () Ġ{ ĊĊĠĠĠĠĠĠĠ ĠviewModel . create Subject ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSubject ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġregistration Number Ġ= Ġstudent Registration Number , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= Ġ" Programming ĠLanguage ĠC ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcode Ġ= Ġ 1 0 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcredit Ġ= Ġ 3 . 0 F ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstudent Registration Number ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ }