package Ġru . mail . pol is . ui . fragments Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Button Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . Global Scope Ċ import Ġkotlinx . coroutines . launch Ċ import Ġru . mail . pol is . R Ċ import Ġru . mail . pol is . notification . Notification Center Ċ import Ġru . mail . pol is . notification . Notification Keeper Exception Ċ import Ġru . mail . pol is . utils . Storage Utils Ċ import Ġru . mail . pol is . view Models . Self Definition ViewModel Ċ Ċ class ĠSelf Definition Fragment Ġ: ĠFragment () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġself Definition ViewModel Ġ= ĠSelf Definition ViewModel () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadd A partment Button : ĠButton ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfind A partment Button : ĠButton ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ self _ definition , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġval Ġemail Ġ= ĠStorage Utils . getCurrent User Email ( require Context ()) ĊĠĠĠĠĠĠĠ ĠGlobal Scope . launch ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġapart ments Ġ= Ġself Definition ViewModel . fetch A partment ( email ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġperson Ġ= Ġself Definition ViewModel . fetch Person ( email ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( person Ġ!= Ġnull Ġ|| Ġapart ments Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . nav _ graph __ list _ of _ people ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠNotification Keeper Exception ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNotification Center . show Default Toast ( require Context (), ĠgetString ( e . getResource String Code ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġadd A partment Button Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview . findViewById ( R . id . fragment _ self _ definition __ button _ rent _ ap artment ) ĊĠĠĠĠĠĠĠ Ġadd A partment Button . setOnClickListener (:: onClick Add A partment ) ĊĊĠĠĠĠĠĠĠ Ġfind A partment Button Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview . findViewById ( R . id . fragment _ self _ definition __ button _ find _ ap artment ) ĊĠĠĠĠĠĠĠ Ġfind A partment Button . setOnClickListener (:: onClick Find A partment ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠonClick Add A partment ( view : ĠView ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . nav _ graph __ add _ ap artment _ fragment ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠonClick Find A partment ( view : ĠView ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . nav _ graph __ advert _ creation _ fragment ) ĊĠĠĠ Ġ} Ċ } Ċ