package Ġcom . example . tracking _ app . ui . todo List Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . example . tracking _ app . R Ċ import Ġcom . example . tracking _ app . database . models . Event Entity Ċ import Ġcom . example . tracking _ app . network . models . Event Road Map Ċ import Ġcom . example . tracking _ app . network . models . Location Ċ import Ġcom . example . tracking _ app . network . models . T ache Items Ċ import Ġcom . example . tracking _ app . network . to Road Map Event Ċ import Ġcom . example . tracking _ app . repository . Road Map Repository Ċ import Ġcom . example . tracking _ app . ui . Events . Events ViewModel Ċ import Ġcom . example . tracking _ app . ui . login . Login Activity Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . Global Scope Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠTODO Fragment Ġ: ĠFragment (), T ache Adapter . On ItemClickListener Ġ{ ĊĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠTODO ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠMy Events Not Validated Ġ: ĠList < T ache Items > ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Provider ( this ). get ( TODO ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġvar Ġroot Ġ= Ġinflater . inflate ( R . layout . t _ o _ d _ o _ fragment , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġvar Ġvertical RecyclerView Ġ= Ġroot . findViewById < RecyclerView >( R . id . T ache RecyclerView ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . navigate Event . observe ( view Lifecycle Owner , Ġandroidx . lifecycle . Observer Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( it ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . navigation Event Done () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġnav Intent Ġ= ĠIntent ( context , ĠLogin Activity :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnav Intent . flags Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIntent . FLAG _ ACTIVITY _ NEW _ TASK Ġor ĠIntent . FLAG _ ACTIVITY _ CLEAR _ TASK ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠstartActivity ( nav Intent ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ ĠGlobal Scope . launch Ġ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroot . findViewById < TextView >( R . id . fullName Agent T aches ). text Ġ= ĠviewModel . GetCurrent User (). lastName +" Ġ"+ viewModel . GetCurrent User (). firstName ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠviewModel . GetAll Events Not Validated (). observe ( view Lifecycle Owner , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMy Events Not Validated Ġ= Ġit ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvertical RecyclerView . adapter Ġ= ĠT ache Adapter ( it , this ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġroot ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Activity Created ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Provider ( this ). get ( TODO ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġ// ĠTODO : ĠUse Ġthe ĠViewModel ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Item Click ( position : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġaction Ġ= ĠTODO Fragment Directions . action TODO Fragment To Event Details Fragment () ĊĠĠĠĠĠĠĠ Ġaction . set My Event Position ( position ) ĊĠĠĠĠĠĠĠ Ġaction . set My Event ID ( My Events Not Validated . get ( position ). eventId ) ĊĠĠĠĠĠĠĠ Ġthis . find Nav Controller (). navigate ( action ) ĊĠĠĠ Ġ} Ċ Ċ }