Initial commit
This commit is contained in:
commit
6072b2ba29
844 changed files with 220532 additions and 0 deletions
59
app/src/main/java/com/aryan/reader/data/RecentFileDao.kt
Normal file
59
app/src/main/java/com/aryan/reader/data/RecentFileDao.kt
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// RecentFileDao.kt
|
||||
package com.aryan.reader.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface RecentFileDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertOrUpdateFile(file: RecentFileEntity)
|
||||
|
||||
@Query("SELECT * FROM recent_files WHERE isDeleted = 0 ORDER BY timestamp DESC")
|
||||
fun getRecentFiles(): Flow<List<RecentFileEntity>>
|
||||
|
||||
@Query("SELECT * FROM recent_files")
|
||||
suspend fun getAllFiles(): List<RecentFileEntity>
|
||||
|
||||
@Query("SELECT * FROM recent_files WHERE isDeleted = 0 ORDER BY timestamp DESC LIMIT :limit")
|
||||
fun getRecentFilesList(limit: Int): List<RecentFileEntity>
|
||||
|
||||
@Query("DELETE FROM recent_files WHERE bookId IN (:bookIds)")
|
||||
suspend fun deleteFilePermanently(bookIds: List<String>)
|
||||
|
||||
@Query("UPDATE recent_files SET isDeleted = 1, isAvailable = 0, lastModifiedTimestamp = :timestamp WHERE bookId IN (:bookIds)")
|
||||
suspend fun markAsDeleted(bookIds: List<String>, timestamp: Long)
|
||||
|
||||
@Query("SELECT * FROM recent_files WHERE lastModifiedTimestamp > :sinceTimestamp")
|
||||
suspend fun getModifiedSince(sinceTimestamp: Long): List<RecentFileEntity>
|
||||
|
||||
@Query("SELECT COUNT(*) FROM recent_files")
|
||||
suspend fun count(): Int
|
||||
|
||||
@Query("SELECT * FROM recent_files WHERE bookId = :bookId")
|
||||
suspend fun getFileByBookId(bookId: String): RecentFileEntity?
|
||||
|
||||
@Query("SELECT * FROM recent_files WHERE uriString = :uriString")
|
||||
suspend fun getFileByUri(uriString: String): RecentFileEntity?
|
||||
|
||||
@Query("DELETE FROM recent_files")
|
||||
suspend fun clearAll()
|
||||
|
||||
@Query("UPDATE recent_files SET lastPositionCfi = :cfi, lastChapterIndex = :chapterIndex, locatorBlockIndex = :blockIndex, locatorCharOffset = :charOffset, progressPercentage = :progress, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
||||
suspend fun updateEpubReadingPosition(bookId: String, cfi: String?, chapterIndex: Int, blockIndex: Int, charOffset: Int, progress: Float, timestamp: Long)
|
||||
|
||||
@Query("UPDATE recent_files SET lastPage = :page, progressPercentage = :progress, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
||||
suspend fun updatePdfReadingPosition(bookId: String, page: Int, progress: Float, timestamp: Long)
|
||||
|
||||
@Query("UPDATE recent_files SET bookmarks = :bookmarksJson, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
||||
suspend fun updateBookmarks(bookId: String, bookmarksJson: String, timestamp: Long)
|
||||
|
||||
@Query("UPDATE recent_files SET isAvailable = 1, uriString = :uriString, timestamp = :timestamp, lastModifiedTimestamp = :timestamp WHERE bookId = :bookId")
|
||||
suspend fun updateBookAvailability(bookId: String, uriString: String, timestamp: Long)
|
||||
|
||||
@Query("UPDATE recent_files SET isRecent = 0, lastModifiedTimestamp = :timestamp WHERE bookId IN (:bookIds)")
|
||||
suspend fun markAsNotRecent(bookIds: List<String>, timestamp: Long)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue