优化 #5574
This commit is contained in:
@@ -121,29 +121,36 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
|
||||
initExploreKinds()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun initExploreKinds() {
|
||||
lifecycleScope.launch {
|
||||
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
|
||||
try {
|
||||
val exploreKinds = viewModel.bookSource?.exploreKinds()?.filter {
|
||||
!it.url.isNullOrBlank()
|
||||
}
|
||||
}
|
||||
@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)
|
||||
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
|
||||
}
|
||||
}
|
||||
@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())
|
||||
val loginInfo = source.getLoginInfoMap()
|
||||
val loginUi = source.loginUi()
|
||||
loginUi?.forEachIndexed { index, rowUi ->
|
||||
when (rowUi.type) {
|
||||
RowUi.Type.text -> ItemSourceEditBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textInputLayout.hint = rowUi.name
|
||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||
}
|
||||
try {
|
||||
loginUi?.forEachIndexed { index, rowUi ->
|
||||
when (rowUi.type) {
|
||||
RowUi.Type.text -> ItemSourceEditBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textInputLayout.hint = rowUi.name
|
||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||
}
|
||||
|
||||
RowUi.Type.password -> ItemSourceEditBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textInputLayout.hint = rowUi.name
|
||||
it.editText.inputType =
|
||||
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT
|
||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||
}
|
||||
RowUi.Type.password -> ItemSourceEditBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textInputLayout.hint = rowUi.name
|
||||
it.editText.inputType =
|
||||
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT
|
||||
it.editText.setText(loginInfo?.get(rowUi.name))
|
||||
}
|
||||
|
||||
RowUi.Type.button -> ItemFilletTextBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
rowUi.style().apply(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textView.text = rowUi.name
|
||||
it.textView.setPadding(16.dpToPx())
|
||||
it.root.onClick {
|
||||
handleButtonClick(source, rowUi, loginUi)
|
||||
RowUi.Type.button -> ItemFilletTextBinding.inflate(
|
||||
layoutInflater,
|
||||
binding.root,
|
||||
false
|
||||
).let {
|
||||
binding.flexbox.addView(it.root)
|
||||
rowUi.style().apply(it.root)
|
||||
it.root.id = index + 1000
|
||||
it.textView.text = rowUi.name
|
||||
it.textView.setPadding(16.dpToPx())
|
||||
it.root.onClick {
|
||||
handleButtonClick(source, rowUi, loginUi)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: NullPointerException) {
|
||||
AppLog.put("登录UI JSON 数据错误", e, true)
|
||||
}
|
||||
binding.toolBar.inflateMenu(R.menu.source_login)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
|
||||
Reference in New Issue
Block a user