修复一个崩溃bug

pull/854/head 3.21.021708
gedoor 4 years ago
parent bc8b4c1caa
commit 9f3be1eea6
  1. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 4
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  6. 6
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  7. 7
      app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  9. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  10. 10
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt
  11. 4
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  12. 6
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  13. 4
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  14. 6
      app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt
  15. 4
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  16. 4
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt
  17. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt

@ -66,12 +66,12 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
adapter.setItems(viewModel.allSources) adapter.setItems(viewModel.allSources)
binding.tvCancel.visible() binding.tvCancel.visible()
binding.tvCancel.setOnClickListener { binding.tvCancel.setOnClickListener {
dismiss() dismissAllowingStateLoss()
} }
binding.tvOk.visible() binding.tvOk.visible()
binding.tvOk.setOnClickListener { binding.tvOk.setOnClickListener {
viewModel.importSelect { viewModel.importSelect {
dismiss() dismissAllowingStateLoss()
} }
} }
upSelectText() upSelectText()

@ -64,12 +64,12 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
adapter.setItems(viewModel.allSources) adapter.setItems(viewModel.allSources)
binding.tvCancel.visible() binding.tvCancel.visible()
binding.tvCancel.setOnClickListener { binding.tvCancel.setOnClickListener {
dismiss() dismissAllowingStateLoss()
} }
binding.tvOk.visible() binding.tvOk.visible()
binding.tvOk.setOnClickListener { binding.tvOk.setOnClickListener {
viewModel.importSelect { viewModel.importSelect {
dismiss() dismissAllowingStateLoss()
} }
} }
upSelectText() upSelectText()

@ -107,7 +107,7 @@ class ChangeCoverDialog : BaseDialogFragment(),
override fun changeTo(coverUrl: String) { override fun changeTo(coverUrl: String) {
callBack?.coverChangeTo(coverUrl) callBack?.coverChangeTo(coverUrl)
dismiss() dismissAllowingStateLoss()
} }
interface CallBack { interface CallBack {

@ -190,7 +190,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
val book = searchBook.toBook() val book = searchBook.toBook()
book.upInfoFromOld(callBack?.oldBook) book.upInfoFromOld(callBack?.oldBook)
callBack?.changeTo(book) callBack?.changeTo(book)
dismiss() dismissAllowingStateLoss()
} }
override val bookUrl: String? override val bookUrl: String?

@ -71,7 +71,9 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView) ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView)
binding.tvOk.setTextColor(requireContext().accentColor) binding.tvOk.setTextColor(requireContext().accentColor)
binding.tvOk.visible() binding.tvOk.visible()
binding.tvOk.setOnClickListener { dismiss() } binding.tvOk.setOnClickListener {
dismissAllowingStateLoss()
}
} }
private fun initData() { private fun initData() {

@ -94,11 +94,13 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
val itemTouchCallback = ItemTouchCallback(adapter) val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = true itemTouchCallback.isCanDrag = true
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView) ItemTouchHelper(itemTouchCallback).attachToRecyclerView(binding.recyclerView)
binding.tvCancel.setOnClickListener { dismiss() } binding.tvCancel.setOnClickListener {
dismissAllowingStateLoss()
}
binding.tvOk.setTextColor(requireContext().accentColor) binding.tvOk.setTextColor(requireContext().accentColor)
binding.tvOk.setOnClickListener { binding.tvOk.setOnClickListener {
callBack?.upGroup(requestCode, groupId) callBack?.upGroup(requestCode, groupId)
dismiss() dismissAllowingStateLoss()
} }
} }

@ -94,14 +94,17 @@ class AutoReadDialog : BaseDialogFragment() {
} }
private fun initEvent() { private fun initEvent() {
binding.llMainMenu.setOnClickListener { callBack?.showMenuBar(); dismiss() } binding.llMainMenu.setOnClickListener {
callBack?.showMenuBar()
dismissAllowingStateLoss()
}
binding.llSetting.setOnClickListener { binding.llSetting.setOnClickListener {
ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog")
} }
binding.llCatalog.setOnClickListener { callBack?.openChapterList() } binding.llCatalog.setOnClickListener { callBack?.openChapterList() }
binding.llAutoPageStop.setOnClickListener { binding.llAutoPageStop.setOnClickListener {
callBack?.autoPageStop() callBack?.autoPageStop()
dismiss() dismissAllowingStateLoss()
} }
} }

@ -183,7 +183,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
binding.ivDelete.setOnClickListener { binding.ivDelete.setOnClickListener {
if (ReadBookConfig.deleteDur()) { if (ReadBookConfig.deleteDur()) {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
dismiss() dismissAllowingStateLoss()
} else { } else {
toastOnUi("数量已是最少,不能删除.") toastOnUi("数量已是最少,不能删除.")
} }

@ -69,7 +69,7 @@ class ClickActionConfigDialog : BaseDialogFragment() {
private fun initViewEvent() { private fun initViewEvent() {
binding.ivClose.setOnClickListener { binding.ivClose.setOnClickListener {
dismiss() dismissAllowingStateLoss()
} }
binding.tvTopLeft.setOnClickListener { binding.tvTopLeft.setOnClickListener {
selectAction { action -> selectAction { action ->

@ -122,13 +122,19 @@ class ReadAloudDialog : BaseDialogFragment() {
} }
private fun initEvent() = with(binding) { private fun initEvent() = with(binding) {
llMainMenu.setOnClickListener { callBack?.showMenuBar(); dismiss() } llMainMenu.setOnClickListener {
callBack?.showMenuBar()
dismissAllowingStateLoss()
}
llSetting.setOnClickListener { llSetting.setOnClickListener {
ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog")
} }
tvPre.setOnClickListener { ReadBook.moveToPrevChapter(upContent = true, toLast = false) } tvPre.setOnClickListener { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
tvNext.setOnClickListener { ReadBook.moveToNextChapter(true) } tvNext.setOnClickListener { ReadBook.moveToNextChapter(true) }
ivStop.setOnClickListener { ReadAloud.stop(requireContext()); dismiss() } ivStop.setOnClickListener {
ReadAloud.stop(requireContext())
dismissAllowingStateLoss()
}
ivPlayPause.setOnClickListener { callBack?.onClickReadAloud() } ivPlayPause.setOnClickListener { callBack?.onClickReadAloud() }
ivPlayPrev.setOnClickListener { ReadAloud.prevParagraph(requireContext()) } ivPlayPrev.setOnClickListener { ReadAloud.prevParagraph(requireContext()) }
ivPlayNext.setOnClickListener { ReadAloud.nextParagraph(requireContext()) } ivPlayNext.setOnClickListener { ReadAloud.nextParagraph(requireContext()) }

@ -125,7 +125,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
} }
} }
tvPadding.setOnClickListener { tvPadding.setOnClickListener {
dismiss() dismissAllowingStateLoss()
callBack?.showPaddingConfig() callBack?.showPaddingConfig()
} }
tvTip.setOnClickListener { tvTip.setOnClickListener {
@ -174,7 +174,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
} }
private fun showBgTextConfig(index: Int): Boolean { private fun showBgTextConfig(index: Int): Boolean {
dismiss() dismissAllowingStateLoss()
changeBg(index) changeBg(index)
callBack?.showBgTextConfig() callBack?.showBgTextConfig()
return true return true

@ -69,16 +69,16 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
tvFooterLeft.visible() tvFooterLeft.visible()
tvFooterLeft.setOnClickListener { tvFooterLeft.setOnClickListener {
removePref(PreferKey.speakEngine) removePref(PreferKey.speakEngine)
dismiss() dismissAllowingStateLoss()
} }
tvOk.visible() tvOk.visible()
tvOk.setOnClickListener { tvOk.setOnClickListener {
putPrefLong(PreferKey.speakEngine, engineId) putPrefLong(PreferKey.speakEngine, engineId)
dismiss() dismissAllowingStateLoss()
} }
tvCancel.visible() tvCancel.visible()
tvCancel.setOnClickListener { tvCancel.setOnClickListener {
dismiss() dismissAllowingStateLoss()
} }
} }

@ -79,14 +79,14 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
itemTouchCallback.isCanDrag = true itemTouchCallback.isCanDrag = true
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(recyclerView) ItemTouchHelper(itemTouchCallback).attachToRecyclerView(recyclerView)
tvCancel.setOnClickListener { tvCancel.setOnClickListener {
dismiss() dismissAllowingStateLoss()
} }
tvOk.setOnClickListener { tvOk.setOnClickListener {
adapter.getItems().forEach { tocRule -> adapter.getItems().forEach { tocRule ->
if (selectedName == tocRule.name) { if (selectedName == tocRule.name) {
val callBack = activity as? CallBack val callBack = activity as? CallBack
callBack?.onTocRegexDialogResult(tocRule.rule) callBack?.onTocRegexDialogResult(tocRule.rule)
dismiss() dismissAllowingStateLoss()
return@setOnClickListener return@setOnClickListener
} }
} }

@ -152,12 +152,12 @@ class FilePickerDialog : DialogFragment(),
when (item?.itemId) { when (item?.itemId) {
R.id.menu_ok -> fileAdapter.currentPath?.let { R.id.menu_ok -> fileAdapter.currentPath?.let {
setData(it) setData(it)
dismiss() dismissAllowingStateLoss()
} }
else -> item?.title?.let { else -> item?.title?.let {
(parentFragment as? CallBack)?.onMenuClick(it.toString()) (parentFragment as? CallBack)?.onMenuClick(it.toString())
(activity as? CallBack)?.onMenuClick(it.toString()) (activity as? CallBack)?.onMenuClick(it.toString())
dismiss() dismissAllowingStateLoss()
} }
} }
return true return true
@ -175,7 +175,7 @@ class FilePickerDialog : DialogFragment(),
allowExtensions?.contains(FileUtils.getExtension(path)) == true allowExtensions?.contains(FileUtils.getExtension(path)) == true
) { ) {
setData(path) setData(path)
dismiss() dismissAllowingStateLoss()
} else { } else {
toastOnUi("不能打开此文件") toastOnUi("不能打开此文件")
} }

@ -58,7 +58,9 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
recyclerView.adapter = adapter recyclerView.adapter = adapter
tvOk.setTextColor(requireContext().accentColor) tvOk.setTextColor(requireContext().accentColor)
tvOk.visible() tvOk.visible()
tvOk.setOnClickListener { dismiss() } tvOk.setOnClickListener {
dismissAllowingStateLoss()
}
appDb.rssSourceDao.liveGroup().observe(viewLifecycleOwner, { appDb.rssSourceDao.liveGroup().observe(viewLifecycleOwner, {
val groups = linkedSetOf<String>() val groups = linkedSetOf<String>()
it.map { group -> it.map { group ->

@ -94,7 +94,7 @@ class FontSelectDialog : BaseDialogFragment(),
) { _, i -> ) { _, i ->
AppConfig.systemTypefaces = i AppConfig.systemTypefaces = i
onDefaultFontChange() onDefaultFontChange()
dismiss() dismissAllowingStateLoss()
} }
}.show() }.show()
} }
@ -223,7 +223,7 @@ class FontSelectDialog : BaseDialogFragment(),
FileUtils.deleteFile(fontFolder.absolutePath) FileUtils.deleteFile(fontFolder.absolutePath)
callBack?.selectFont(docItem.uri.toString()) callBack?.selectFont(docItem.uri.toString())
}.onSuccess { }.onSuccess {
dialog?.dismiss() dismissAllowingStateLoss()
} }
} }

@ -188,7 +188,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference
label.isChecked = item.toString() == dialogValue label.isChecked = item.toString() == dialogValue
root.setOnClickListener { root.setOnClickListener {
onChanged?.invoke(item.toString()) onChanged?.invoke(item.toString())
this@IconDialog.dismiss() this@IconDialog.dismissAllowingStateLoss()
} }
} }
} }

Loading…
Cancel
Save