package Ġio . github . gus and rian os . fox for reddit . view models Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġandroidx . paging . Paging Data Ċ import Ġandroidx . paging . cached In Ċ import Ġio . github . gus and rian os . fox for reddit . data . models . Comment Listing Ċ import Ġio . github . gus and rian os . fox for reddit . data . models . Data Ċ import Ġio . github . gus and rian os . fox for reddit . data . models . Single Post Ċ import Ġio . github . gus and rian os . fox for reddit . data . models . Submit Response Ċ import Ġio . github . gus and rian os . fox for reddit . data . models . single post . more children . More Children Ċ import Ġio . github . gus and rian os . fox for reddit . data . repositories . Post Repository Ċ Ċ class ĠPost ViewModel ( private Ġval Ġm Post Repository : ĠPost Repository ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġvar Ġposts : ĠLive Data < Paging Data < Data >> ? Ġ= Ġnull ĊĊĠĠĠ Ġfun Ġget Posts ( sub reddit : ĠString , Ġfilter : ĠString , Ġtime : ĠString , Ġapplication : ĠApplication ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ: ĠLive Data < Paging Data < Data >> Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( posts Ġ!= Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġposts !! ĊĠĠĠĠĠĠĠ Ġposts Ġ= Ġm Post Repository . get Posts ( sub reddit , Ġfilter , Ġtime , Ġapplication ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. cached In ( viewModel Scope ) ĊĠĠĠĠĠĠĠ Ġreturn Ġposts !! ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdelete Cached () Ġ{ ĊĠĠĠĠĠĠĠ Ġposts Ġ= Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġvote Post ( dir : ĠString , Ġid : ĠString , Ġapplication : ĠApplication ) Ġ{ ĊĠĠĠĠĠĠĠ Ġm Post Repository . vote Post ( dir , Ġid , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Single Post ( permalink : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Single Post > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . get Single Post ( permalink , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Single Post Comments ( permalink : ĠString , Ġapplication : ĠApplication ): ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLive Data < Comment Listing > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . get Single Post Comments ( permalink , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget More Children ( link Id : ĠString , Ġchildren : ĠString , Ġapplication : ĠApplication ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ: ĠLive Data < More Children > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . get More Children ( link Id , Ġchildren , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsubmit Text ( type : ĠString , Ġsub reddit : ĠString , Ġtitle : ĠString , Ġurl : ĠString , Ġtext : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġn sf w : ĠBoolean , Ġspo iler : ĠBoolean , Ġfl air _ id : ĠString , Ġfl air _ text : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġapplication : ĠApplication ): ĠLive Data < Submit Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . submit Text ( type , Ġsub reddit , Ġtitle , Ġurl , Ġtext , Ġn sf w , Ġspo iler , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfl air _ id , Ġfl air _ text , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsave Post ( id : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . save Post ( id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġun Save Post ( id : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . un Save Post ( id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġhide Post ( id : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . hide Post ( id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġun Hide Post ( id : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . un Hide Post ( id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġreport Post ( thing _ id : ĠString , Ġreason : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . report Post ( thing _ id , Ġreason , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġselect Fl air ( sub reddit : ĠString , Ġlink : ĠString , Ġtemplate Id : ĠString , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . select Fl air ( sub reddit , Ġlink , Ġtemplate Id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark NS FW ( id : ĠString , Ġis NS FW : ĠBoolean , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . mark NS FW ( id , Ġis NS FW , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark Spo iler ( id : ĠString , Ġis Spo iler : ĠBoolean , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . mark Spo iler ( id , Ġis Spo iler , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdelete Submission ( id : ĠString , Ġapplication : ĠApplication ): ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . delete Submission ( id , Ġapplication ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġedit Submission ( text : ĠString , Ġthing _ id : ĠString , Ġapplication : ĠApplication ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ: ĠLive Data < Boolean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġm Post Repository . edit Submission ( text , Ġthing _ id , Ġapplication ) ĊĠĠĠ Ġ} Ċ }