diff --git a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt index 2fb5a4085..5c0524302 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt @@ -13,8 +13,9 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.Bookmark -import io.legado.app.databinding.DialogEditTextBinding +import io.legado.app.databinding.DialogBookmarkBinding import io.legado.app.databinding.FragmentBookmarkBinding +import io.legado.app.help.coroutine.Coroutine import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.widget.recycler.VerticalDivider @@ -84,18 +85,19 @@ class BookmarkFragment : VMBaseFragment(R.layout.fragment_ @SuppressLint("InflateParams") override fun onLongClick(bookmark: Bookmark) { requireContext().alert(R.string.bookmark) { - val alertBinding = DialogEditTextBinding.inflate(layoutInflater) - message = bookmark.bookText - customView { - alertBinding.apply { - editView.setHint(R.string.note_content) - editView.setText(bookmark.content) - }.root + message = bookmark.chapterName + val alertBinding = DialogBookmarkBinding.inflate(layoutInflater).apply { + editBookText.setText(bookmark.bookText) + editView.setText(bookmark.content) } + customView = alertBinding.root yesButton { - alertBinding.editView.text?.toString()?.let { editContent -> - bookmark.content = editContent - App.db.bookmarkDao.update(bookmark) + alertBinding.apply { + Coroutine.async { + bookmark.bookText = editBookText.text.toString() + bookmark.content = editView.text.toString() + App.db.bookmarkDao.insert(bookmark) + } } } noButton()