pull/1303/head
gedoor 3 years ago
parent cc16a8e2d2
commit c93b133b1e
  1. 37
      app/src/main/java/io/legado/app/ui/login/RuleUiLoginDialog.kt

@ -17,6 +17,10 @@ import io.legado.app.ui.widget.text.EditText
import io.legado.app.ui.widget.text.TextInputLayout import io.legado.app.ui.widget.text.TextInputLayout
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import splitties.views.onClick import splitties.views.onClick
class RuleUiLoginDialog : BaseDialogFragment() { class RuleUiLoginDialog : BaseDialogFragment() {
@ -101,21 +105,30 @@ class RuleUiLoginDialog : BaseDialogFragment() {
} }
} }
} }
if (loginData.isEmpty()) { launch(IO) {
bookSource.removeLoginInfo() if (loginData.isEmpty()) {
return@setOnMenuItemClickListener true bookSource.removeLoginInfo()
} withContext(Main) {
if (bookSource.putLoginInfo(GSON.toJson(loginData))) { dismiss()
bookSource.getLoginJs()?.let { }
try { } else if (bookSource.putLoginInfo(GSON.toJson(loginData))) {
bookSource.evalJS(it) bookSource.getLoginJs()?.let {
toastOnUi(R.string.success) try {
} catch (e: Exception) { bookSource.evalJS(it)
e.printStackTrace() toastOnUi(R.string.success)
toastOnUi(e.localizedMessage ?: "ERROR") withContext(Main) {
dismiss()
}
} catch (e: Exception) {
e.printStackTrace()
toastOnUi("error:${e.localizedMessage}")
}
} }
} }
} }
} }
} }
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true

Loading…
Cancel
Save