From f7f1c880f5d90d61acff9e7891b2ca7ab74e902c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 30 Dec 2020 21:37:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/toc/BookmarkFragment.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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()