|
|
@ -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() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
launch(IO) { |
|
|
|
if (loginData.isEmpty()) { |
|
|
|
if (loginData.isEmpty()) { |
|
|
|
bookSource.removeLoginInfo() |
|
|
|
bookSource.removeLoginInfo() |
|
|
|
return@setOnMenuItemClickListener true |
|
|
|
withContext(Main) { |
|
|
|
|
|
|
|
dismiss() |
|
|
|
} |
|
|
|
} |
|
|
|
if (bookSource.putLoginInfo(GSON.toJson(loginData))) { |
|
|
|
} else if (bookSource.putLoginInfo(GSON.toJson(loginData))) { |
|
|
|
bookSource.getLoginJs()?.let { |
|
|
|
bookSource.getLoginJs()?.let { |
|
|
|
try { |
|
|
|
try { |
|
|
|
bookSource.evalJS(it) |
|
|
|
bookSource.evalJS(it) |
|
|
|
toastOnUi(R.string.success) |
|
|
|
toastOnUi(R.string.success) |
|
|
|
|
|
|
|
withContext(Main) { |
|
|
|
|
|
|
|
dismiss() |
|
|
|
|
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
e.printStackTrace() |
|
|
|
e.printStackTrace() |
|
|
|
toastOnUi(e.localizedMessage ?: "ERROR") |
|
|
|
toastOnUi("error:${e.localizedMessage}") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return@setOnMenuItemClickListener true |
|
|
|
return@setOnMenuItemClickListener true |
|
|
|