Просмотр исходного кода

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

Xwite 3 лет назад
Родитель
Сommit
82d7787746

+ 1 - 1
app/src/main/java/io/legado/app/constant/AppConst.kt

@@ -25,7 +25,7 @@ object AppConst {
 
     const val MAX_THREAD = 9
 
-    const val DEFAULT_WEBDAV_ID = -1
+    const val DEFAULT_WEBDAV_ID = -1L
 
     val SCRIPT_ENGINE: RhinoScriptEngine by lazy {
         RhinoScriptEngine()

+ 9 - 17
app/src/main/java/io/legado/app/ui/book/import/remote/ServerConfigDialog.kt

@@ -67,7 +67,6 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
     }
 
     private fun upConfigView(server: Server?) {
-        binding.etId.setText(server?.id?.toString())
         binding.etName.setText(server?.name)
         binding.spType.setSelection(
             when (server?.type) {
@@ -109,14 +108,7 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
     }
 
     private fun getServer(): Server? {
-        val id = kotlin.runCatching {
-            binding.etId.text.toString().toLong()
-        }.getOrNull()
-        if (id == null) {
-            toastOnUi("id不能为空")
-            return null
-        }
-        val server = viewModel.mServer?.copy(id = id) ?: Server(id = id)
+        val server = viewModel.mServer?.copy() ?: Server()
         server.name = binding.etName.text.toString()
         server.type = when (binding.spType.selectedItemPosition) {
             else -> Server.TYPE.WEBDAV
@@ -139,15 +131,15 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
     }
 
 
-    override fun onDismiss(dialog: DialogInterface) {
-        super.onDismiss(dialog)
-        ((parentFragment as? Callback) ?: (activity as? Callback))
-            ?.onDialogDismiss("serverConfig")
-    }
+    // override fun onDismiss(dialog: DialogInterface) {
+        // super.onDismiss(dialog)
+       // ((parentFragment as? Callback) ?: (activity as? Callback))
+           // ?.onDialogDismiss("serverConfig")
+    // }
 
-    interface Callback {
+    // interface Callback {
 
-        fun onDialogDismiss(tag: String)
+        // fun onDialogDismiss(tag: String)
 
-    }
+    // }
 }

+ 0 - 15
app/src/main/res/layout/dialog_webdav_server.xml

@@ -28,21 +28,6 @@
             app:popupTheme="@style/AppTheme.PopupOverlay"
             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
             android:id="@+id/til_name"
             android:layout_width="match_parent"