修复一个崩溃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)
binding.tvCancel.visible()
binding.tvCancel.setOnClickListener {
dismiss()
dismissAllowingStateLoss()
}
binding.tvOk.visible()
binding.tvOk.setOnClickListener {
viewModel.importSelect {
dismiss()
dismissAllowingStateLoss()
}
}
upSelectText()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save