package Ġn hd ph u ong . com . manga . data . local Ċ Ċ import Ġandroidx . room . Dao Ċ import Ġandroidx . room . Insert Ċ import Ġandroidx . room . On Conflict Strategy Ċ import Ġandroidx . room . Query Ċ import Ġio . reactivex . Maybe Ċ import Ġio . reactivex . Single Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ DOWN LOADED _ BOOK Ġas ĠDOWN LOADED _ BOOK Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ BOOK _ TAG Ġas ĠBO OK _ TAG Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ DOWN LOADED _ IMAGE Ġas ĠDOWN LOADED _ IMAGE Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ PENDING _ DOWNLOAD _ BOOK Ġas ĠP ENDING _ DOWNLOAD _ BOOK Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . BOOK _ ID Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . CREATED _ AT Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . ID Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TYPE Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . LOCAL _ PATH Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . LAST _ VISIT ED _ PAGE Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . MEDIA _ ID Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . NUM _ FA V OR ITES Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . NUM _ PAGES Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . RAW _ BOOK Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . READ ING _ TIMES Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . SCAN L ATOR Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ BLOCK ED _ BOOK Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TABLE _ LAST _ VISIT ED _ PAGE Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TAG _ ID Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TITLE _ EN G Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TITLE _ J AP ANE SE Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . TITLE _ PRE TTY Ċ import Ġn hd ph u ong . com . manga . Constants . Companion . UPLOAD _ DATE Ċ import Ġn hd ph u ong . com . manga . data . entity . Blocked Book Ċ import Ġn hd ph u ong . com . manga . data . entity . Favorite Book Ċ import Ġn hd ph u ong . com . manga . data . entity . Recent Book Ċ import Ġn hd ph u ong . com . manga . data . local . model . Book Image Model Ċ import Ġn hd ph u ong . com . manga . data . local . model . Book Tag Model Ċ import Ġn hd ph u ong . com . manga . data . local . model . Downloaded Book Model Ċ import Ġn hd ph u ong . com . manga . data . local . model . Last Vis ited Page Ċ import Ġn hd ph u ong . com . manga . data . local . model . Image Usage Type Ċ import Ġn hd ph u ong . com . manga . data . local . model . Pending Download Book Ċ Ċ /* Ċ Ġ* ĠCreated Ġby Ġn hd ph u ong Ġon Ġ 6 / 8 / 1 8 . Ċ Ġ*/ Ċ @ Dao Ċ interface ĠBook DAO Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠREC ENT _ BOOK _ TABLE : ĠString Ġ= Ġ" Recent Book " ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠF AV OR ITE _ BOOK _ TABLE : ĠString Ġ= Ġ" Favorite Book " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert Recent Books ( var arg Ġrecent Book Entities : ĠRecent Book ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert Favorite Books ( var arg Ġfavorite Book Entities : ĠF avorite Book ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġinsert Blocked Books ( var arg Ġblocked Book Entities : ĠBlock ed Book ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġadd Downloaded Book ( downloaded Books : ĠList < Downloaded Book Model >): ĠList < Long > ĊĊĠĠĠ Ġ@ Query (" update Ġ$ DOWN LOADED _ BOOK Ġset Ġ$ MEDIA _ ID Ġ= Ġ: media Id , Ġ$ TITLE _ EN G Ġ= Ġ: title Eng , Ġ$ TITLE _ J AP ANE SE Ġ= Ġ: title J apanese , Ġ$ TITLE _ PRE TTY Ġ= Ġ: title Pretty , Ġ$ SCAN L ATOR Ġ= Ġ: scan lator , Ġ$ UPLOAD _ DATE Ġ= Ġ: upload Date , Ġ$ NUM _ PAGES Ġ= Ġ: num Of Pages , Ġ$ NUM _ FA V OR ITES Ġ= Ġ: num Of F avorites ") ĊĠĠĠ Ġfun Ġupdate Downloaded Book ( ĊĠĠĠĠĠĠĠ Ġmedia Id : ĠString , ĊĠĠĠĠĠĠĠ Ġtitle Eng : ĠString , ĊĠĠĠĠĠĠĠ Ġtitle J apanese : ĠString , ĊĠĠĠĠĠĠĠ Ġtitle Pretty : ĠString , ĊĠĠĠĠĠĠĠ Ġscan lator : ĠString , ĊĠĠĠĠĠĠĠ Ġupload Date : ĠLong , ĊĠĠĠĠĠĠĠ ĠnumOf Pages : ĠInt , ĊĠĠĠĠĠĠĠ ĠnumOf F avorites : ĠInt ĊĠĠĠ Ġ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ DOWN LOADED _ BOOK Ġorder Ġby Ġrow id Ġdesc ") ĊĠĠĠ Ġfun ĠgetAll Downloaded Books (): ĠSingle < List < Downloaded Book Model >> ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġadd Tag ListOf Book ( tag List : ĠList < Book Tag Model >): ĠList < Long > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ BOOK _ TAG Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun ĠgetAll Tags Of Book ( book Id : ĠString ): ĠSingle < List < Book Tag Model >> ĊĊĠĠĠ Ġ@ Query (" select Ġ$ TAG _ ID Ġfrom Ġ$ BOOK _ TAG Ġgroup Ġby Ġ$ TAG _ ID Ġorder Ġby Ġcount ($ TAG _ ID ) Ġdesc Ġlimit Ġ: maximum Entries ") ĊĠĠĠ Ġfun Ġget Most Used Tags ( maximum Entries : ĠInt ): ĠSingle < List < Long >> ĊĊĠĠĠ Ġ@ Query (" select Ġ$ BOOK _ ID Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġorder Ġby Ġ$ READ ING _ TIMES Ġdesc ") ĊĠĠĠ Ġfun Ġget Recent Book Ids For Recommendation (): ĠSingle < List < String >> ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġadd Image Of Book ( book Image Model : ĠBook Image Model ): ĠLong ĊĊĠĠĠ Ġ@ Query (" select Ġ$ LOCAL _ PATH Ġfrom Ġ$ DOWN LOADED _ IMAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id Ġand Ġ$ TYPE Ġ= Ġ: usage Type Ġlimit Ġ 1 ") ĊĠĠĠ Ġfun Ġget First Image Path Of Book ( book Id : ĠString , Ġ@ Image Usage Type Ġusage Type : ĠString ): ĠSingle < String > ĊĊĠĠĠ Ġ@ Query (" select Ġ$ LOCAL _ PATH Ġfrom Ġ$ DOWN LOADED _ IMAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id Ġand Ġ$ TYPE Ġ= Ġ: usage Type Ġand Ġ$ LOCAL _ PATH Ġ!= Ġ'' Ġlimit Ġ 1 ") ĊĠĠĠ Ġfun Ġget First NotBlank Image Path Of Book ( ĊĠĠĠĠĠĠĠ Ġbook Id : ĠString , Ġ@ Image Usage Type Ġusage Type : ĠString ĊĠĠĠ Ġ): ĠSingle < String > ĊĊĠĠĠ Ġ@ Query (" select Ġ$ LOCAL _ PATH Ġfrom Ġ$ DOWN LOADED _ IMAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id Ġand Ġ$ TYPE Ġ= Ġ: usage Type ") ĊĠĠĠ Ġfun ĠgetImage Paths Of Book ( book Id : ĠString , Ġ@ Image Usage Type Ġusage Type : ĠString ): ĠSingle < List < String >> ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ DOWN LOADED _ IMAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun ĠgetAll Images Of Book ( book Id : ĠString ): ĠSingle < List < Book Image Model >> ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ DOWN LOADED _ IMAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġclear Downloaded Images ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ DOWN LOADED _ BOOK Ġwhere Ġ$ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġdelete Book ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġdelete Recent Book ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġdelete Favorite Book ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġorder Ġby Ġ$ CREATED _ AT Ġdesc Ġlimit Ġ: limit Ġoffset Ġ: offset ") ĊĠĠĠ Ġfun Ġget Recent Books ( limit : ĠInt , Ġoffset : ĠInt ): ĠList < Recent Book > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġget Recent Book ( book Id : ĠString ): ĠSingle < Recent Book > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġget Recent Book S ynchronously ( book Id : ĠString ): ĠRecent Book ? ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE Ġorder Ġby Ġ$ CREATED _ AT Ġdesc Ġlimit Ġ: limit Ġoffset Ġ: offset ") ĊĠĠĠ Ġfun Ġget Favorite Books ( limit : ĠInt , Ġoffset : ĠInt ): ĠList < Favorite Book > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ RAW _ BOOK Ġ= Ġ'' ") ĊĠĠĠ Ġfun Ġget Empty Recent Books (): ĠSingle < List < Recent Book >> ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE Ġwhere Ġ$ RAW _ BOOK Ġ= Ġ'' ") ĊĠĠĠ Ġfun Ġget Empty Favorite Books (): ĠSingle < List < Favorite Book >> ĊĊĠĠĠ Ġ@ Query (" select Ġ$ BOOK _ ID Ġfrom Ġ$ REC ENT _ BOOK _ TABLE ") ĊĠĠĠ Ġfun Ġget Recent Book Ids (): ĠList < String > ĊĊĠĠĠ Ġ@ Query (" select Ġ$ BOOK _ ID Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE ") ĊĠĠĠ Ġfun Ġget Favorite Book Ids (): ĠList < String > ĊĊĠĠĠ Ġ@ Query (" select Ġcount (*) Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ RAW _ BOOK Ġ= Ġ'' ") ĊĠĠĠ Ġfun Ġget Empty Recent Books Count (): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġcount (*) Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE Ġwhere Ġ$ RAW _ BOOK Ġ= Ġ'' ") ĊĠĠĠ Ġfun Ġget Empty Favorite Books Count (): ĠInt ĊĊĠĠĠ Ġ@ Query (" update Ġ$ REC ENT _ BOOK _ TABLE Ġset Ġ$ RAW _ BOOK Ġ= Ġ: raw Book Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġupdate Raw Recent Book ( book Id : ĠString , Ġraw Book : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" update Ġ$ FA V OR ITE _ BOOK _ TABLE Ġset Ġ$ RAW _ BOOK Ġ= Ġ: raw Book Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġupdate Raw Favorite Book ( book Id : ĠString , Ġraw Book : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġcount (*) Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġget Favorite Book Count ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ$ BOOK _ ID Ġfrom Ġ$ REC ENT _ BOOK _ TABLE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġget Recent Book Id ( book Id : ĠString ): ĠString ĊĊĠĠĠ Ġ@ Query (" select Ġcount (*) Ġfrom Ġ$ REC ENT _ BOOK _ TABLE ") ĊĠĠĠ Ġfun Ġget Recent Book Count (): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġcount (*) Ġfrom Ġ$ FA V OR ITE _ BOOK _ TABLE ") ĊĠĠĠ Ġfun Ġget Favorite Book Count (): ĠInt ĊĊĠĠĠ Ġ// ĠLast Ġvisited Ġpage ĊĠĠĠ Ġ@ Query (" select Ġ$ LAST _ VISIT ED _ PAGE Ġfrom Ġ$ TABLE _ LAST _ VISIT ED _ PAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun ĠgetLast Vis ited Page ( book Id : ĠString ): ĠSingle < Int > ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġfun Ġadd Last Vis ited Page ( var arg Ġlast Vis ited Page : ĠLast Vis ited Page ): ĠList < Long > ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ TABLE _ LAST _ VISIT ED _ PAGE Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġdelete Last Vis ited Page ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ$ BOOK _ ID Ġfrom Ġ$ TABLE _ BLOCK ED _ BOOK ") ĊĠĠĠ Ġfun Ġget Blocked Book Ids (): ĠList < String > ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . IGNORE ) ĊĠĠĠ Ġfun Ġadd Pending Download Book ( pending Download Book : ĠPending Download Book ): ĠLong ĊĊĠĠĠ Ġ@ Query (" delete Ġfrom Ġ$ PENDING _ DOWNLOAD _ BOOK Ġwhere Ġ$ BOOK _ ID Ġ= Ġ: book Id ") ĊĠĠĠ Ġfun Ġremove Book From Pending Download List ( book Id : ĠString ): ĠInt ĊĊĠĠĠ Ġ@ Query (" select Ġ$ RAW _ BOOK Ġfrom Ġ$ PENDING _ DOWNLOAD _ BOOK Ġorder Ġby ĠRow Id Ġasc Ġlimit Ġ 1 Ġoffset Ġ 0 ") ĊĠĠĠ Ġfun Ġget Ol dest Pending Download Book (): ĠMaybe < String > ĊĊĠĠĠ Ġ@ Query (" select Ġ* Ġfrom Ġ$ PENDING _ DOWNLOAD _ BOOK Ġorder Ġby ĠRow Id Ġasc Ġlimit Ġ: limit Ġoffset Ġ 0 ") ĊĠĠĠ Ġfun Ġget Pending Download Books ( limit : ĠInt ): ĠSingle < List < Pending Download Book >> ĊĊĠĠĠ Ġ@ Query (" select Ġcount ($ BOOK _ ID ) Ġfrom Ġ$ PENDING _ DOWNLOAD _ BOOK ") ĊĠĠĠ Ġfun Ġget Pending Download Book Count (): ĠSingle < Int > Ċ } Ċ