pull/1319/head
gedoor 3 years ago
parent 3fcd954070
commit 82a218947e
  1. 15
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 17
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  3. 17
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  4. 16
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  5. 9
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  6. 8
      app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt
  7. 11
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  9. 9
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt
  10. 11
      app/src/main/java/io/legado/app/ui/dict/DictDialog.kt
  11. 7
      app/src/main/java/io/legado/app/ui/document/FilePickerDialog.kt
  12. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt
  13. 16
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt
  14. 16
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  15. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt

@ -27,11 +27,8 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.dp import io.legado.app.utils.*
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
/** /**
@ -46,12 +43,10 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
source: String, source: String,
finishOnDismiss: Boolean = false finishOnDismiss: Boolean = false
) { ) {
ImportBookSourceDialog().apply { fragmentManager.showDialog<ImportBookSourceDialog> {
arguments = Bundle().apply { putString("source", source)
putString("source", source) putBoolean("finishOnDismiss", finishOnDismiss)
putBoolean("finishOnDismiss", finishOnDismiss) }
}
}.show(fragmentManager, "importBookSource")
} }
} }

@ -26,27 +26,24 @@ import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.dp import io.legado.app.utils.*
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
class ImportReplaceRuleDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class ImportReplaceRuleDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
companion object { companion object {
fun start( fun start(
fragmentManager: FragmentManager, fragmentManager: FragmentManager,
source: String, source: String,
finishOnDismiss: Boolean = false finishOnDismiss: Boolean = false
) { ) {
ImportReplaceRuleDialog().apply { fragmentManager.showDialog<ImportReplaceRuleDialog> {
arguments = Bundle().apply { putString("source", source)
putString("source", source) putBoolean("finishOnDismiss", finishOnDismiss)
putBoolean("finishOnDismiss", finishOnDismiss) }
}
}.show(fragmentManager, "importReplaceRule")
} }
} }
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)

@ -27,11 +27,8 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.dp import io.legado.app.utils.*
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
/** /**
* 导入rss源弹出窗口 * 导入rss源弹出窗口
@ -39,18 +36,18 @@ import io.legado.app.utils.visible
class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
companion object { companion object {
fun start( fun start(
fragmentManager: FragmentManager, fragmentManager: FragmentManager,
source: String, source: String,
finishOnDismiss: Boolean = false finishOnDismiss: Boolean = false
) { ) {
ImportRssSourceDialog().apply { fragmentManager.showDialog<ImportRssSourceDialog> {
arguments = Bundle().apply { putString("source", source)
putString("source", source) putBoolean("finishOnDismiss", finishOnDismiss)
putBoolean("finishOnDismiss", finishOnDismiss) }
}
}.show(fragmentManager, "importRssSource")
} }
} }
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)

@ -14,6 +14,7 @@ import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogChangeCoverBinding import io.legado.app.databinding.DialogChangeCoverBinding
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.showDialog
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize import io.legado.app.utils.windowSize
@ -23,17 +24,14 @@ class ChangeCoverDialog : BaseDialogFragment(),
CoverAdapter.CallBack { CoverAdapter.CallBack {
companion object { companion object {
const val tag = "changeCoverDialog"
fun show(fragmentManager: FragmentManager, name: String, author: String) {
fun show(manager: FragmentManager, name: String, author: String) { fragmentManager.showDialog<ChangeCoverDialog> {
val fragment = ChangeCoverDialog().apply { putString("name", name)
val bundle = Bundle() putString("author", author)
bundle.putString("name", name)
bundle.putString("author", author)
arguments = bundle
} }
fragment.show(manager, tag)
} }
} }
private val binding by viewBinding(DialogChangeCoverBinding::bind) private val binding by viewBinding(DialogChangeCoverBinding::bind)

@ -37,13 +37,10 @@ class ChangeSourceDialog : BaseDialogFragment(),
const val tag = "changeSourceDialog" const val tag = "changeSourceDialog"
fun show(manager: FragmentManager, name: String, author: String) { fun show(manager: FragmentManager, name: String, author: String) {
val fragment = ChangeSourceDialog().apply { manager.showDialog<ChangeSourceDialog> {
val bundle = Bundle() putString("name", name)
bundle.putString("name", name) putString("author", author)
bundle.putString("author", author)
arguments = bundle
} }
fragment.show(manager, tag)
} }
} }

@ -21,11 +21,9 @@ class GroupEditDialog : BaseDialogFragment() {
companion object { companion object {
fun start(fragmentManager: FragmentManager, bookGroup: BookGroup? = null) { fun start(fragmentManager: FragmentManager, bookGroup: BookGroup? = null) {
GroupEditDialog().apply { fragmentManager.showDialog<GroupEditDialog> {
arguments = Bundle().apply { putParcelable("group", bookGroup)
putParcelable("group", bookGroup) }
}
}.show(fragmentManager, "bookGroupEdit")
} }
} }

@ -26,6 +26,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.showDialog
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize import io.legado.app.utils.windowSize
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
@ -38,14 +39,12 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
const val tag = "groupSelectDialog" const val tag = "groupSelectDialog"
fun show(manager: FragmentManager, groupId: Long, requestCode: Int = -1) { fun show(manager: FragmentManager, groupId: Long, requestCode: Int = -1) {
val fragment = GroupSelectDialog().apply { manager.showDialog<GroupSelectDialog> {
val bundle = Bundle() putLong("groupId", groupId)
bundle.putLong("groupId", groupId) putInt("requestCode", requestCode)
bundle.putInt("requestCode", requestCode)
arguments = bundle
} }
fragment.show(manager, tag)
} }
} }
private val binding by viewBinding(DialogBookGroupPickerBinding::bind) private val binding by viewBinding(DialogBookGroupPickerBinding::bind)

@ -539,7 +539,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
return true return true
} }
R.id.menu_dict -> { R.id.menu_dict -> {
DictDialog.dict(supportFragmentManager, selectedText) DictDialog.show(supportFragmentManager, selectedText)
return true return true
} }
} }

@ -11,6 +11,7 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Bookmark import io.legado.app.data.entities.Bookmark
import io.legado.app.databinding.DialogBookmarkBinding import io.legado.app.databinding.DialogBookmarkBinding
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.showDialog
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -21,11 +22,9 @@ class BookmarkDialog : BaseDialogFragment() {
companion object { companion object {
fun start(fragmentManager: FragmentManager, bookmark: Bookmark) { fun start(fragmentManager: FragmentManager, bookmark: Bookmark) {
BookmarkDialog().apply { fragmentManager.showDialog<BookmarkDialog> {
arguments = Bundle().apply { putParcelable("bookmark", bookmark)
putParcelable("bookmark", bookmark) }
}
}.show(fragmentManager, "bookMarkDialog")
} }
} }

@ -13,6 +13,7 @@ import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogDictBinding import io.legado.app.databinding.DialogDictBinding
import io.legado.app.utils.invisible import io.legado.app.utils.invisible
import io.legado.app.utils.showDialog
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -23,12 +24,10 @@ class DictDialog : BaseDialogFragment() {
companion object { companion object {
fun dict(manager: FragmentManager, word: String) { fun show(manager: FragmentManager, word: String) {
DictDialog().apply { manager.showDialog<DictDialog> {
val bundle = Bundle() putString("word", word)
bundle.putString("word", word) }
arguments = bundle
}.show(manager, word)
} }
} }

@ -9,11 +9,11 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogFileChooserBinding import io.legado.app.databinding.DialogFileChooserBinding
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.document.HandleFileContract.Companion.DIR import io.legado.app.ui.document.HandleFileContract.Companion.DIR
@ -26,7 +26,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
import java.io.File import java.io.File
class FilePickerDialog : DialogFragment(), class FilePickerDialog : BaseDialogFragment(),
Toolbar.OnMenuItemClickListener, Toolbar.OnMenuItemClickListener,
FileAdapter.CallBack, FileAdapter.CallBack,
PathAdapter.CallBack { PathAdapter.CallBack {
@ -88,8 +88,7 @@ class FilePickerDialog : DialogFragment(),
return inflater.inflate(R.layout.dialog_file_chooser, container, true) return inflater.inflate(R.layout.dialog_file_chooser, container, true)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.toolBar.setBackgroundColor(primaryColor) binding.toolBar.setBackgroundColor(primaryColor)
view.setBackgroundResource(R.color.background_card) view.setBackgroundResource(R.color.background_card)
arguments?.let { arguments?.let {

@ -138,7 +138,7 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
override fun getItem(position: Int): Fragment { override fun getItem(position: Int): Fragment {
val group = bookGroups[position] val group = bookGroups[position]
return BooksFragment.newInstance(position, group.groupId) return BooksFragment(position, group.groupId)
} }
override fun getCount(): Int { override fun getCount(): Int {

@ -37,18 +37,14 @@ import kotlin.math.max
/** /**
* 书架界面 * 书架界面
*/ */
class BooksFragment : BaseFragment(R.layout.fragment_books), class BooksFragment() : BaseFragment(R.layout.fragment_books),
BaseBooksAdapter.CallBack { BaseBooksAdapter.CallBack {
companion object { constructor(position: Int, groupId: Long) : this() {
fun newInstance(position: Int, groupId: Long): BooksFragment { val bundle = Bundle()
return BooksFragment().apply { bundle.putInt("position", position)
val bundle = Bundle() bundle.putLong("groupId", groupId)
bundle.putInt("position", position) arguments = bundle
bundle.putLong("groupId", groupId)
arguments = bundle
}
}
} }
private val binding by viewBinding(FragmentBooksBinding::bind) private val binding by viewBinding(FragmentBooksBinding::bind)

@ -26,18 +26,14 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragment_rss_articles), class RssArticlesFragment() : VMBaseFragment<RssArticlesViewModel>(R.layout.fragment_rss_articles),
BaseRssArticlesAdapter.CallBack { BaseRssArticlesAdapter.CallBack {
companion object { constructor(sortName: String, sortUrl: String) : this() {
fun create(sortName: String, sortUrl: String): RssArticlesFragment { val bundle = Bundle()
return RssArticlesFragment().apply { bundle.putString("sortName", sortName)
val bundle = Bundle() bundle.putString("sortUrl", sortUrl)
bundle.putString("sortName", sortName) arguments = bundle
bundle.putString("sortUrl", sortUrl)
arguments = bundle
}
}
} }
private val binding by viewBinding(FragmentRssArticlesBinding::bind) private val binding by viewBinding(FragmentRssArticlesBinding::bind)

@ -135,7 +135,7 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
override fun getItem(position: Int): Fragment { override fun getItem(position: Int): Fragment {
val sort = sortList[position] val sort = sortList[position]
return RssArticlesFragment.create(sort.first, sort.second) return RssArticlesFragment(sort.first, sort.second)
} }
override fun getCount(): Int { override fun getCount(): Int {

Loading…
Cancel
Save