package Ġru . gr ak hell . phot io . core . util Ċ /* Ċ Copyright Ġ 2 0 2 2 ĠD mit ri i ĠZ . Ċ Ċ Licensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ you Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ You Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat ĊĊĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ċ Unless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ distributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ WITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ See Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ limitations Ġunder Ġthe ĠLicense . Ċ */ Ċ import Ġandroid . annotation . Suppress Lint Ċ import Ġandroid . net . Uri Ċ import Ġandroid . os . Build Ċ import Ġandroid . provider . Media Store Ċ import Ġandroid . util . Log Ċ import Ġandroidx . arch . core . executor . Arch Task Executor Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . paging . DataSource Ċ import Ġandroidx . paging . Paged List Ċ import Ġcom . had il q . live event . Live Event Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġjava . io . PrintWriter Ċ import Ġjava . io . String Writer Ċ import Ġjava . util . concurrent . Executor Ċ Ċ fun Ġ< T > ĠLive Data < T >. to Single Event (): ĠLive Event < T > Ġ{ ĊĠĠĠ Ġval Ġresult Ġ= ĠLive Event < T >() ĊĠĠĠ Ġresult . add Source ( this ) Ġ{ ĊĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġit ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġresult Ċ } Ċ Ċ @ Experimental Cor outines Api Ċ @ Suppress Lint (" Restricted Api ") Ċ fun Ġ< Key , ĠValue > ĠDataSource . Factory < Key , ĠValue >. to Flow ( ĊĠĠĠ Ġconfig : ĠP aged List . Config , ĊĠĠĠ Ġinitial Load Key : ĠKey ? Ġ= Ġnull , ĊĠĠĠ Ġboundary Callback : ĠP aged List . Boundary Callback < Value >? Ġ= Ġnull , ĊĠĠĠ Ġnotify Executor : ĠExecutor Ġ= ĠArch Task Executor . get MainThread Executor (), ĊĠĠĠ Ġfetch Executor : ĠExecutor Ġ= ĠArch Task Executor . get IO Thread Executor () Ċ ): ĠFlow < Paged List < Value >> Ġ{ ĊĠĠĠ Ġreturn ĠFlow Paged List Builder ( this , config , initial Load Key , boundary Callback , Ġnotify Executor , Ġfetch Executor ) ĊĠĠĠĠĠĠĠ Ġ. build Flow () Ċ } Ċ Ċ fun ĠThrowable . print Trace To Log ( owner : ĠAny ) Ġ{ ĊĠĠĠ Ġval Ġerr Ġ= ĠString Writer () ĊĠĠĠ Ġthis . printStackTrace ( PrintWriter ( err )) ĊĠĠĠ ĠLog . w ( owner . toString (), err . toString ()) Ċ } Ċ Ċ object ĠDownload Location Ġ{ ĊĠĠĠ Ġval Ġuri : ĠUri Ġ= Ġif Ġ( Build . VERSION . SDK _ INT Ġ>= ĠBuild . VERSION _ CODES . Q ) ĊĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠ ĠMedia Store . Images . Media . getContent Uri ( Media Store . VOLUME _ EXTERNAL _ PRIMARY )} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠĠĠ ĠMedia Store . Images . Media . EXTERNAL _ CONTENT _ URI ĊĠĠĠ Ġ} Ċ }