package Ġst 2 3 5 . com . github . se am car ving . presentation . gallery Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġkotlinx . coroutines . launch Ċ import Ġst 2 3 5 . com . github . se am car ving . data . State ful Media Request Ċ import Ġst 2 3 5 . com . github . se am car ving . inter actors . Gallery Interactor Ċ import Ġst 2 3 5 . com . github . se am car ving . inter actors . State ful Media Interactor Ċ import Ġst 2 3 5 . com . github . se am car ving . inter actors . models . Image Info Ċ import Ġst 2 3 5 . com . github . se am car ving . presentation . utils . require Value Ċ import Ġst 2 3 5 . com . github . se am car ving . utils . Mutable Live Event Ċ Ċ class ĠGallery ViewModel ( ĊĠĠĠ Ġprivate Ġval Ġgallery Interactor : ĠGallery Interactor , ĊĠĠĠ Ġprivate Ġval Ġstate ful Media Interactor : ĠStateful Media Interactor Ċ ): ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġimages LiveData Ġ= ĠMutable LiveData < List < Image Info >>() ĊĠĠĠ Ġprivate Ġval Ġselected Image LiveData Ġ= ĠMutable LiveData < Image Info >() ĊĊĠĠĠ Ġprivate Ġval Ġmedia Requests Data Ġ= ĠMutable Live Event < State ful Media Request >() ĊĊĠĠĠ Ġfun Ġobserve Selected Image (): ĠLive Data < Image Info > Ġ= Ġselected Image LiveData ĊĊĠĠĠ Ġfun Ġupdate Selected Image ( selected Image Info : ĠImage Info ) Ġ{ ĊĠĠĠĠĠĠĠ Ġselected Image LiveData . value Ġ= Ġselected Image Info ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġobserve Album Images (): ĠLive Data < List < Image Info >> Ġ= Ġimages LiveData ĊĊĠĠĠ Ġfun Ġobserve Media Requests (): ĠLive Data < State ful Media Request > Ġ= Ġmedia Requests Data ĊĊĠĠĠ Ġfun Ġrequest Empty File () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmedia Requests Data . setValue ( state ful Media Interactor . fetch Empty File ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġconsume Pending File () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmedia Requests Data . setValue ( state ful Media Interactor . consume Pending File ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġobtain Current Album Page () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġitems Ġ= Ġgallery Interactor . load Current Page () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġimages LiveData . value Ġ= Ġitems ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġload Next Album Page () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġitems Ġ= Ġgallery Interactor . load Next Page () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġimages LiveData . value Ġ= Ġitems ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġremove Media () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġimage Info Ġ= Ġselected Image LiveData . require Value () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgallery Interactor . remove Media ( image Info ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmedia Requests Data . setValue ( State ful Media Request . Media Removed ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }