From eac2e521500640844755a2ae847f766c4a9dae9d Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 15 Sep 2021 15:42:53 +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 --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 4 ++-- .../io/legado/app/ui/book/toc/BookmarkDialog.kt | 14 ++++---------- .../io/legado/app/ui/book/toc/BookmarkFragment.kt | 3 ++- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 9ec383eeb..82b157b12 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -251,7 +251,7 @@ class ReadBookActivity : ReadBookBaseActivity(), chapterName = page.title bookText = page.text.trim() } - BookmarkDialog.start(supportFragmentManager, bookmark) + supportFragmentManager.showDialog(BookmarkDialog(bookmark)) } } R.id.menu_copy_text -> @@ -512,7 +512,7 @@ class ReadBookActivity : ReadBookBaseActivity(), if (bookmark == null) { toastOnUi(R.string.create_bookmark_error) } else { - BookmarkDialog.start(supportFragmentManager, bookmark) + supportFragmentManager.showDialog(BookmarkDialog(bookmark)) } return true } diff --git a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt index f71bbb168..b64f4f6b4 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt @@ -4,29 +4,23 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.FragmentManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.data.appDb import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.DialogBookmarkBinding import io.legado.app.lib.theme.primaryColor -import io.legado.app.utils.showDialog import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class BookmarkDialog : BaseDialogFragment() { +class BookmarkDialog() : BaseDialogFragment() { - companion object { - - fun start(fragmentManager: FragmentManager, bookmark: Bookmark) { - fragmentManager.showDialog { - putParcelable("bookmark", bookmark) - } + constructor(bookmark: Bookmark) : this() { + arguments = Bundle().apply { + putParcelable("bookmark", bookmark) } - } private val binding by viewBinding(DialogBookmarkBinding::bind) 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 4d937e4f4..46af3510b 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,6 +13,7 @@ import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.FragmentBookmarkBinding import io.legado.app.lib.theme.ATH import io.legado.app.ui.widget.recycler.VerticalDivider +import io.legado.app.utils.showDialog import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.Job import kotlinx.coroutines.flow.collect @@ -67,6 +68,6 @@ class BookmarkFragment : VMBaseFragment(R.layout.fragment_bookmark } override fun onLongClick(bookmark: Bookmark) { - BookmarkDialog.start(childFragmentManager, bookmark) + childFragmentManager.showDialog(BookmarkDialog(bookmark)) } } \ No newline at end of file