package Ġedu . u wp . app factory . rus d . ui . settings Ċ Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġkotlinx . android . synt hetic . main . activity _ settings .* Ċ import Ġkotlinx . android . synt hetic . main . settings _ subscription _ item .* Ċ Ċ import Ġedu . u wp . app factory . rus d . R Ċ import Ġedu . u wp . app factory . rus d . data . local . Realm Topic Repository Ċ import Ġedu . u wp . app factory . rus d . data . local . Realm UserRepository Ċ import Ġedu . u wp . app factory . rus d . data . model . Subscription Ċ import Ġedu . u wp . app factory . rus d . data . model . Topic Ċ Ċ class ĠSettings Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġuser Repository Ġ= ĠRealm UserRepository () ĊĠĠĠ Ġprivate Ġval Ġtopic Repository Ġ= ĠRealm Topic Repository ( this ) ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ settings ) ĊĠĠĠĠĠĠĠ Ġsupport ActionBar ?. set Display Home As Up Enabled ( true ) ĊĊĠĠĠĠĠĠĠ Ġsubscriptions _ recycler _ view . layout Manager Ġ= ĠLinearLayoutManager ( this ) ĊĠĠĠĠĠĠĠ Ġval ĠcurrentUser Ġ= Ġuser Repository . getCurrent User () ĊĠĠĠĠĠĠĠ Ġval Ġsubscriptions Ġ= Ġmutable ListOf < Subscription >() ĊĠĠĠĠĠĠĠ Ġtopic Repository . get Topics ()?. forEach Ġ{ Ġtopic Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubscriptions . add ( Subscription ( topic , ĠcurrentUser !! )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsubscription Adapter Ġ= ĠSettings Subscription Adapter ( subscriptions , Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubscriptions _ recycler _ view . adapter Ġ= Ġsubscription Adapter ĊĠĠĠĠĠĠĠ Ġregister For ContextMenu ( subscriptions _ recycler _ view ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ