pull/1319/head
gedoor 3 years ago
parent 6eba220292
commit a5ea1b32bb
  1. 12
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  2. 11
      app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  6. 9
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  7. 7
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt

@ -6,7 +6,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.R
@ -14,26 +13,21 @@ import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogChangeCoverBinding
import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.applyTint
import io.legado.app.utils.showDialog
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.windowSize
class ChangeCoverDialog : BaseDialogFragment(),
class ChangeCoverDialog() : BaseDialogFragment(),
Toolbar.OnMenuItemClickListener,
CoverAdapter.CallBack {
companion object {
fun show(fragmentManager: FragmentManager, name: String, author: String) {
fragmentManager.showDialog<ChangeCoverDialog> {
constructor(name: String, author: String) : this() {
arguments = Bundle().apply {
putString("name", name)
putString("author", author)
}
}
}
private val binding by viewBinding(DialogChangeCoverBinding::bind)
private var callBack: CallBack? = null
private val viewModel: ChangeCoverViewModel by viewModels()

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -16,18 +15,14 @@ import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import splitties.views.onClick
class GroupEditDialog : BaseDialogFragment() {
class GroupEditDialog() : BaseDialogFragment() {
companion object {
fun start(fragmentManager: FragmentManager, bookGroup: BookGroup? = null) {
fragmentManager.showDialog<GroupEditDialog> {
constructor(bookGroup: BookGroup? = null) : this() {
arguments = Bundle().apply {
putParcelable("group", bookGroup)
}
}
}
private val binding by viewBinding(DialogBookGroupEditBinding::bind)
private val viewModel by viewModels<GroupViewModel>()
private var bookGroup: BookGroup? = null

@ -25,6 +25,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint
import io.legado.app.utils.showDialog
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
import io.legado.app.utils.windowSize
@ -89,7 +90,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_add -> GroupEditDialog.start(childFragmentManager)
R.id.menu_add -> childFragmentManager.showDialog(GroupEditDialog())
}
return true
}
@ -121,7 +122,9 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
binding.run {
tvEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let { bookGroup ->
GroupEditDialog.start(childFragmentManager, bookGroup)
childFragmentManager.showDialog(
GroupEditDialog(bookGroup)
)
}
}
swShow.setOnCheckedChangeListener { buttonView, isChecked ->

@ -110,7 +110,9 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_add -> GroupEditDialog.start(childFragmentManager)
R.id.menu_add -> childFragmentManager.showDialog(
GroupEditDialog()
)
}
return true
}
@ -152,7 +154,9 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
}
tvEdit.setOnClickListener {
GroupEditDialog.start(childFragmentManager, getItem(holder.layoutPosition))
childFragmentManager.showDialog(
GroupEditDialog(getItem(holder.layoutPosition))
)
}
}
}

@ -262,7 +262,9 @@ class BookInfoActivity :
private fun initOnClick() = binding.run {
ivCover.setOnClickListener {
viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
supportFragmentManager.showDialog(
ChangeCoverDialog(it.name, it.author)
)
}
}
tvRead.setOnClickListener {

@ -11,10 +11,7 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book
import io.legado.app.databinding.ActivityBookInfoEditBinding
import io.legado.app.ui.book.changecover.ChangeCoverDialog
import io.legado.app.utils.FileUtils
import io.legado.app.utils.SelectImageContract
import io.legado.app.utils.externalFiles
import io.legado.app.utils.readUri
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
class BookInfoEditActivity :
@ -55,7 +52,9 @@ class BookInfoEditActivity :
private fun initEvent() = binding.run {
tvChangeCover.setOnClickListener {
viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
supportFragmentManager.showDialog(
ChangeCoverDialog(it.name, it.author)
)
}
}
tvSelectCover.setOnClickListener {

@ -26,10 +26,7 @@ import io.legado.app.ui.book.info.BookInfoActivity
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.main.bookshelf.BaseBookshelfFragment
import io.legado.app.utils.cnCompare
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.observeEvent
import io.legado.app.utils.startActivity
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect
@ -195,7 +192,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
putExtra("name", item.name)
putExtra("author", item.author)
}
is BookGroup -> GroupEditDialog.start(childFragmentManager, item)
is BookGroup -> childFragmentManager.showDialog(GroupEditDialog(item))
}
}

Loading…
Cancel
Save