优化 #5574
This commit is contained in:
@@ -121,29 +121,36 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
|
|||||||
initExploreKinds()
|
initExploreKinds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
private fun initExploreKinds() {
|
private fun initExploreKinds() {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val exploreKinds = viewModel.bookSource?.exploreKinds()?.filter {
|
try {
|
||||||
!it.url.isNullOrBlank()
|
val exploreKinds = viewModel.bookSource?.exploreKinds()?.filter {
|
||||||
}
|
!it.url.isNullOrBlank()
|
||||||
exploreKinds?.firstOrNull()?.let {
|
|
||||||
binding.textFx.text = "${it.title}::${it.url}"
|
|
||||||
if (it.title.startsWith("ERROR:")) {
|
|
||||||
adapter.addItem("获取发现出错\n${it.url}")
|
|
||||||
openOrCloseHelp(false)
|
|
||||||
searchView.clearFocus()
|
|
||||||
return@launch
|
|
||||||
}
|
}
|
||||||
}
|
exploreKinds?.firstOrNull()?.let {
|
||||||
@Suppress("USELESS_ELVIS")
|
binding.textFx.text = "${it.title}::${it.url}"
|
||||||
exploreKinds?.map { it.title ?: "" }?.let { exploreKindTitles ->
|
if (it.title.startsWith("ERROR:")) {
|
||||||
binding.textFx.onLongClick {
|
adapter.addItem("获取发现出错\n${it.url}")
|
||||||
selector("选择发现", exploreKindTitles) { _, index ->
|
openOrCloseHelp(false)
|
||||||
val explore = exploreKinds[index]
|
searchView.clearFocus()
|
||||||
binding.textFx.text = "${explore.title}::${explore.url}"
|
return@launch
|
||||||
searchView.setQuery(binding.textFx.text, true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Suppress("USELESS_ELVIS")
|
||||||
|
exploreKinds?.map { it.title ?: "" }?.let { exploreKindTitles ->
|
||||||
|
binding.textFx.onLongClick {
|
||||||
|
selector("选择发现", exploreKindTitles) { _, index ->
|
||||||
|
val explore = exploreKinds[index]
|
||||||
|
binding.textFx.text = "${explore.title}::${explore.url}"
|
||||||
|
searchView.setQuery(binding.textFx.text, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
adapter.addItem("获取发现出错 JSON 数据错误\n$e")
|
||||||
|
openOrCloseHelp(false)
|
||||||
|
searchView.clearFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,47 +56,51 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login, true) {
|
|||||||
binding.toolBar.title = getString(R.string.login_source, source.getTag())
|
binding.toolBar.title = getString(R.string.login_source, source.getTag())
|
||||||
val loginInfo = source.getLoginInfoMap()
|
val loginInfo = source.getLoginInfoMap()
|
||||||
val loginUi = source.loginUi()
|
val loginUi = source.loginUi()
|
||||||
loginUi?.forEachIndexed { index, rowUi ->
|
try {
|
||||||
when (rowUi.type) {
|
loginUi?.forEachIndexed { index, rowUi ->
|
||||||
RowUi.Type.text -> ItemSourceEditBinding.inflate(
|
when (rowUi.type) {
|
||||||
layoutInflater,
|
RowUi.Type.text -> ItemSourceEditBinding.inflate(
|
||||||
binding.root,
|
layoutInflater,
|
||||||
false
|
binding.root,
|
||||||
).let {
|
false
|
||||||
binding.flexbox.addView(it.root)
|
).let {
|
||||||
it.root.id = index + 1000
|
binding.flexbox.addView(it.root)
|
||||||
it.textInputLayout.hint = rowUi.name
|
it.root.id = index + 1000
|
||||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
it.textInputLayout.hint = rowUi.name
|
||||||
}
|
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||||
|
}
|
||||||
|
|
||||||
RowUi.Type.password -> ItemSourceEditBinding.inflate(
|
RowUi.Type.password -> ItemSourceEditBinding.inflate(
|
||||||
layoutInflater,
|
layoutInflater,
|
||||||
binding.root,
|
binding.root,
|
||||||
false
|
false
|
||||||
).let {
|
).let {
|
||||||
binding.flexbox.addView(it.root)
|
binding.flexbox.addView(it.root)
|
||||||
it.root.id = index + 1000
|
it.root.id = index + 1000
|
||||||
it.textInputLayout.hint = rowUi.name
|
it.textInputLayout.hint = rowUi.name
|
||||||
it.editText.inputType =
|
it.editText.inputType =
|
||||||
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT
|
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT
|
||||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
RowUi.Type.button -> ItemFilletTextBinding.inflate(
|
RowUi.Type.button -> ItemFilletTextBinding.inflate(
|
||||||
layoutInflater,
|
layoutInflater,
|
||||||
binding.root,
|
binding.root,
|
||||||
false
|
false
|
||||||
).let {
|
).let {
|
||||||
binding.flexbox.addView(it.root)
|
binding.flexbox.addView(it.root)
|
||||||
rowUi.style().apply(it.root)
|
rowUi.style().apply(it.root)
|
||||||
it.root.id = index + 1000
|
it.root.id = index + 1000
|
||||||
it.textView.text = rowUi.name
|
it.textView.text = rowUi.name
|
||||||
it.textView.setPadding(16.dpToPx())
|
it.textView.setPadding(16.dpToPx())
|
||||||
it.root.onClick {
|
it.root.onClick {
|
||||||
handleButtonClick(source, rowUi, loginUi)
|
handleButtonClick(source, rowUi, loginUi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
AppLog.put("登录UI JSON 数据错误", e, true)
|
||||||
}
|
}
|
||||||
binding.toolBar.inflateMenu(R.menu.source_login)
|
binding.toolBar.inflateMenu(R.menu.source_login)
|
||||||
binding.toolBar.menu.applyTint(requireContext())
|
binding.toolBar.menu.applyTint(requireContext())
|
||||||
|
|||||||
Reference in New Issue
Block a user