package Ġcom . xy o ye . common _ component . database . dao Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . room . Dao Ċ import Ġandroidx . room . Insert Ċ import Ġandroidx . room . On Conflict Strategy Ċ import Ġandroidx . room . Query Ċ import Ġcom . xy o ye . data _ component . bean . Folder Bean Ċ import Ġcom . xy o ye . data _ component . entity . Video Entity Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġx yo ye Ġon Ġ 2 0 2 0 / 7 / 2 9 . Ċ Ġ*/ Ċ Ċ @ Dao Ċ interface ĠVideo Dao Ġ{ ĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġvideo ") ĊĠĠĠ Ġsuspend Ġfun ĠgetAll (): ĠMutable List < Video Entity > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġvideo ĠWHERE Ġfolder _ path Ġ= Ġ(: folder Path )") ĊĠĠĠ Ġfun Ġget Video In Folder ( folder Path : ĠString ): ĠLive Data < Mutable List < Video Entity >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġvideo ĠWHERE Ġfolder _ path Ġ= Ġ(: folder Path )") ĊĠĠĠ Ġsuspend Ġfun Ġget Video In Folder Suspend ( folder Path : ĠString ): ĠMutable List < Video Entity > ĊĊĠĠĠ Ġ// SELECT Ġold . folder , COUNT (* ), new . filter ĊĠĠĠ Ġ// FROM Ġfile ĠAS Ġold ĊĠĠĠ Ġ// Left ĠJOIN Ġ( SELECT Ġfolder , filter ĠFROM Ġfile ĠWHERE Ġfilter Ġ= Ġ' 1 ' ĠGROUP ĠBY Ġfolder ) ĠAS Ġnew ĠON Ġnew . folder Ġ= Ġold . folder ĊĠĠĠ Ġ// GROUP ĠBY Ġold . folder ĊĠĠĠ Ġ@ Query (" SELECT Ġvideo . folder _ path , COUNT (*) ĠAS Ġfile _ count , Ġfilter _ table . filter Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" FROM Ġvideo Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" LEFT ĠJOIN Ġ( ĠSELECT Ġfolder _ path , Ġfilter ĠFROM Ġvideo ĠWHERE Ġfilter Ġ= Ġ(: is Filter ) ĠGROUP ĠBY Ġfolder _ path ) ĠAS Ġfilter _ table Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" ON Ġfilter _ table . folder _ path Ġ= Ġvideo . folder _ path Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" GROUP ĠBY Ġvideo . folder _ path ") ĊĠĠĠ Ġfun ĠgetAll Folder ( is Filter : ĠBoolean Ġ= Ġtrue ): ĠLive Data < Mutable List < Folder Bean >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġfolder _ path , COUNT (*) ĠAS Ġfile _ count , filter ĠFROM Ġvideo ĠWHERE Ġfilter Ġ= Ġ(: is Filter ) ĠGROUP ĠBY Ġfolder _ path ") ĊĠĠĠ Ġsuspend Ġfun Ġget Folder By Filter ( is Filter : ĠBoolean Ġ= Ġfalse ): ĠMutable List < Folder Bean > ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġvideo ĠWHERE Ġfilter Ġ= Ġ 0 ĠAND Ġfile _ path ĠLIKE Ġ(: keyword )") ĊĠĠĠ Ġfun Ġsearch Video ( keyword : ĠString ): ĠLive Data < Mutable List < Video Entity >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġvideo ĠWHERE Ġfilter Ġ= Ġ 0 ĠAND Ġfolder _ path Ġ= Ġ(: folder Path ) ĠAND Ġfile _ path ĠLIKE Ġ(: keyword )") ĊĠĠĠ Ġfun Ġsearch Video In Folder ( keyword : ĠString , Ġfolder Path : ĠString ?): ĠLive Data < Mutable List < Video Entity >> ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġsuspend Ġfun Ġinsert ( var arg Ġentities : ĠVideo Entity ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġvideo ĠWHERE Ġfile _ path Ġ= Ġ(: filePath )") ĊĠĠĠ Ġsuspend Ġfun Ġdelete By Path ( filePath : ĠString ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġvideo ĠWHERE Ġextend Ġ= Ġ(: is Extend )") ĊĠĠĠ Ġsuspend Ġfun Ġdelete Extend ( is Extend : ĠBoolean Ġ= Ġtrue ) ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġvideo ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete All () ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġvideo ĠSET Ġdan mu _ path Ġ= Ġ(: dan mu Path ), Ġdan mu _ id Ġ= Ġ(: dan mu Id ) ĠWHERE Ġfile _ path Ġ= Ġ(: filePath )") ĊĠĠĠ Ġsuspend Ġfun Ġupdate Dan mu ( filePath : ĠString , Ġdan mu Path : ĠString ?, Ġdan mu Id : ĠInt Ġ= Ġ 0 ) ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġvideo ĠSET Ġsubtitle _ path Ġ= Ġ(: subtitle Path ) ĠWHERE Ġfile _ path Ġ= Ġ(: filePath )") ĊĠĠĠ Ġsuspend Ġfun Ġupdate Subtitle ( filePath : ĠString , Ġsubtitle Path : ĠString ?) ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġvideo ĠSET Ġfilter Ġ= Ġ(: filter ) ĠWHERE Ġfolder _ path Ġ= Ġ(: folder Path )") ĊĠĠĠ Ġsuspend Ġfun Ġupdate Folder Filter ( filter : ĠBoolean , Ġfolder Path : ĠString ) Ċ }