修改添加服务器配置时不回调 id自动生成

This commit is contained in:
Xwite
2023-03-10 19:43:29 +08:00
parent 6d11d4e244
commit aeb727b40b
3 changed files with 10 additions and 33 deletions
@@ -25,7 +25,7 @@ object AppConst {
const val MAX_THREAD = 9 const val MAX_THREAD = 9
const val DEFAULT_WEBDAV_ID = -1 const val DEFAULT_WEBDAV_ID = -1L
val SCRIPT_ENGINE: RhinoScriptEngine by lazy { val SCRIPT_ENGINE: RhinoScriptEngine by lazy {
RhinoScriptEngine() RhinoScriptEngine()
@@ -67,7 +67,6 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
} }
private fun upConfigView(server: Server?) { private fun upConfigView(server: Server?) {
binding.etId.setText(server?.id?.toString())
binding.etName.setText(server?.name) binding.etName.setText(server?.name)
binding.spType.setSelection( binding.spType.setSelection(
when (server?.type) { when (server?.type) {
@@ -109,14 +108,7 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
} }
private fun getServer(): Server? { private fun getServer(): Server? {
val id = kotlin.runCatching { val server = viewModel.mServer?.copy() ?: Server()
binding.etId.text.toString().toLong()
}.getOrNull()
if (id == null) {
toastOnUi("id不能为空")
return null
}
val server = viewModel.mServer?.copy(id = id) ?: Server(id = id)
server.name = binding.etName.text.toString() server.name = binding.etName.text.toString()
server.type = when (binding.spType.selectedItemPosition) { server.type = when (binding.spType.selectedItemPosition) {
else -> Server.TYPE.WEBDAV else -> Server.TYPE.WEBDAV
@@ -139,15 +131,15 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
} }
override fun onDismiss(dialog: DialogInterface) { // override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog) // super.onDismiss(dialog)
((parentFragment as? Callback) ?: (activity as? Callback)) // ((parentFragment as? Callback) ?: (activity as? Callback))
?.onDialogDismiss("serverConfig") // ?.onDialogDismiss("serverConfig")
} // }
interface Callback { // interface Callback {
fun onDialogDismiss(tag: String) // fun onDialogDismiss(tag: String)
} // }
} }
@@ -28,21 +28,6 @@
app:popupTheme="@style/AppTheme.PopupOverlay" app:popupTheme="@style/AppTheme.PopupOverlay"
app:titleTextAppearance="@style/ToolbarTitle" /> app:titleTextAppearance="@style/ToolbarTitle" />
<io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ID"
tools:ignore="HardcodedText">
<io.legado.app.lib.theme.view.ThemeEditText
android:id="@+id/et_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numeric="integer"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.TextInputLayout <io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_name" android:id="@+id/til_name"
android:layout_width="match_parent" android:layout_width="match_parent"