|
|
|
@ -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 |
|
|
|
|