优化书签删除

pull/289/head
gedoor 4 years ago
parent 0cdad0747e
commit 5bcd004c21
  1. 8
      app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/chapterlist/BookmarkFragment.kt

@ -1,10 +1,7 @@
package io.legado.app.data.dao package io.legado.app.data.dao
import androidx.paging.DataSource import androidx.paging.DataSource
import androidx.room.Dao import androidx.room.*
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.legado.app.data.entities.Bookmark import io.legado.app.data.entities.Bookmark
@ -23,6 +20,9 @@ interface BookmarkDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg bookmark: Bookmark) fun insert(vararg bookmark: Bookmark)
@Delete
fun delete(vararg bookmark: Bookmark)
@Query("delete from bookmarks where bookUrl = :bookUrl and chapterName like '%'||:chapterName||'%'") @Query("delete from bookmarks where bookUrl = :bookUrl and chapterName like '%'||:chapterName||'%'")
fun delByBookmark(bookUrl: String, chapterName: String) fun delByBookmark(bookUrl: String, chapterName: String)

@ -73,6 +73,6 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
} }
override fun delBookmark(bookmark: Bookmark) { override fun delBookmark(bookmark: Bookmark) {
App.db.bookmarkDao().delByBookmark(bookmark.bookUrl, bookmark.chapterName) App.db.bookmarkDao().delete(bookmark)
} }
} }
Loading…
Cancel
Save