pull/1303/head
gedoor 3 years ago
parent cc16a8e2d2
commit c93b133b1e
  1. 19
      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.utils.*
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
class RuleUiLoginDialog : BaseDialogFragment() {
@ -101,21 +105,30 @@ class RuleUiLoginDialog : BaseDialogFragment() {
}
}
}
launch(IO) {
if (loginData.isEmpty()) {
bookSource.removeLoginInfo()
return@setOnMenuItemClickListener true
withContext(Main) {
dismiss()
}
if (bookSource.putLoginInfo(GSON.toJson(loginData))) {
} else if (bookSource.putLoginInfo(GSON.toJson(loginData))) {
bookSource.getLoginJs()?.let {
try {
bookSource.evalJS(it)
toastOnUi(R.string.success)
withContext(Main) {
dismiss()
}
} catch (e: Exception) {
e.printStackTrace()
toastOnUi(e.localizedMessage ?: "ERROR")
toastOnUi("error:${e.localizedMessage}")
}
}
}
}
}
}
return@setOnMenuItemClickListener true

Loading…
Cancel
Save